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

Pytest Style: test_persistence.py #1470

Merged
merged 2 commits into from Jul 13, 2017

Conversation

utkbansal
Copy link
Member

Fixes #

Changes made in this Pull Request:

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

@utkbansal
Copy link
Member Author

@kain88-de Have a look at test_unpickle_missing in TestAtomGroupPickle. That case fails. I think that has something to do with del not working with fixtures?




# def setUp(self):
Copy link
Member

Choose a reason for hiding this comment

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

This needs removing

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't cleaned this up because the tests are still failing. Need to fix that first.

# Kill AtomGroup and Universe
del self.ag_n
del self.universe_n
del ag_n
Copy link
Member

@orbeckst orbeckst Jul 11, 2017

Choose a reason for hiding this comment

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

I don't think that del makes sense with these fixtures.

Try not to pass them as arguments and leave out the del lines. Maybe they never appear... but in this case, I have no idea what the deep pytest magic actually does.

You should also be able to remove the gc.collect() call.

Copy link
Member

Choose a reason for hiding this comment

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

So the del might not be playing nice with the fixtures, but it's essential to the test. These tests are trying to see what happens when a Universe goes out of scope (is deleted and garbage collected).

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

You might be able to leave out the fixtures and then not need to explicitly del them – if pytest only creates the fixture for each method.

@richardjgowers
Copy link
Member

@utkbansal fot the tests which rely on del on a Universe, try rewriting these to not use a fixture, but instead just put the setup inside the test method and see if it starts working again.

@richardjgowers richardjgowers self-assigned this Jul 12, 2017
@utkbansal
Copy link
Member Author

@richardjgowers The test does work that way. But it's a hack.

@richardjgowers
Copy link
Member

@utkbansal the test relies on the Universe becoming garbage collected, so I think having the fixture hold a reference to the Universe is breaking the test. I can't really see a way round a fixture providing an object but not retaining a reference to it.

@utkbansal
Copy link
Member Author

@richardjgowers Anything left here?

@richardjgowers richardjgowers merged commit d4b27a6 into MDAnalysis:develop Jul 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants