Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some test modernization #425

Merged
merged 22 commits into from
Dec 14, 2021
Merged

Some test modernization #425

merged 22 commits into from
Dec 14, 2021

Conversation

liamhuber
Copy link
Member

@liamhuber liamhuber commented Nov 15, 2021

A bunch of tests weren't passing on my macbook, so I'm fixing that and simultaneously updating them to use more modern syntax (mostly the custom test case classes from base and state).

@liamhuber
Copy link
Member Author

Ok, so I actually did not put much effort into modernizing the sphinx and vasp tests. I think they could probably benefit greatly from pyiron_base._tests.TestWithProject, but I will be a little lazy here and leave that to the sphinx/vasp users (you know who you are and I'll probably ping you for review once this isn't a draft 😉)

@coveralls
Copy link

coveralls commented Nov 29, 2021

Pull Request Test Coverage Report for Build 1534426928

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 69.839%

Totals Coverage Status
Change from base Build 1531836487: 0.0%
Covered Lines: 11441
Relevant Lines: 16382

💛 - Coveralls

I'm not totally happy with this. There is some serious hijinks going on when we explicitly instantiate a class compared to when we create it with one of the tool kits and the JobType wrapper. Everything winds up in the right place (because the underlying ProjectHDFio are the same) but the actual project instance was getting decoupled. I fought with this for waaay too long and now I give up and just manually reconnect the project instance -- everything works beautifully after that. We really need to do some deep dives in pyiron_base though, because the code is riddled with docstrings that say `project` arguments are type `Project`, but they're lying and the type is actually `ProjectHDFio`. I'm not fixing that in this PR though.
Remove duplicate code
Test runners handle things fine without this
I'm the one who wrote them, so it seems fair
CI complains about it. I don't have any idea why as it is totally there in base, but whatever.
@liamhuber liamhuber marked this pull request as ready for review November 30, 2021 21:25
@liamhuber liamhuber requested a review from samwaseda November 30, 2021 21:25
@liamhuber
Copy link
Member Author

@samwaseda you were saying earlier that you wanted to spend more time reviewing unit tests, right? 😜

@liamhuber
Copy link
Member Author

I'm also a little sketched that the diff is so big. A lot of that looks like it should already be in master from #424 and other recent PRs...Maybe there is some refresh on github's side that I need to figure out?

# Conflicts:
#	pyiron_atomistics/atomistics/structure/neighbors.py
@liamhuber
Copy link
Member Author

@samwaseda bump

Copy link
Member

@samwaseda samwaseda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well to be honest I don't understand much of the changes but I trust you :D


for i, struct in enumerate(job.iter_structures()):
# breakpoint()
self.assertTrue(np.allclose(job.output.positions[i], struct.positions))
self.assertTrue(np.allclose(job.output.cells[i], struct.cell.array))
self.assertTrue(np.allclose(job.output.indices[i], struct.indices))

if __name__ == "__main__":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the tests don't work in the terminal I'd like to keep these ones

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sorry, I didn't see this in the mobile app.

Anyhow, it really necessary? I guess if you do python tests/atomistics/job/test_atomistic.py it is, but if you do python -m unittest discover tests/atomistics/job it will run this and the other ones there... but maybe you can append /test_atomistic.py to get just these? Tbh I haven't played around with it much from command line, but I'm 99% sure you can swing it this way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, with python -m unittest path/to/test_file.py you run all tests in this file (If you point to one specific one, you do not need to discover). So Sam, just make an alias run_test_py="python -m unittest discover " and you may fire any directory you want by run_test_py test_dir :)

@liamhuber
Copy link
Member Author

Well to be honest I don't understand much of the changes but I trust you :D

😝 well I don't trust me, but the tests are passing and that gives me some confidence, haha

@liamhuber liamhuber merged commit c9a03af into master Dec 14, 2021
@delete-merged-branch delete-merged-branch bot deleted the get_tests_passing_local branch December 14, 2021 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants