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 analysis/test_hole.py #1539

Merged
merged 3 commits into from
Jul 26, 2017

Conversation

utkbansal
Copy link
Member

Fixes #

Changes made in this Pull Request:

PR Checklist

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


from MDAnalysisTests.datafiles import PDB_HOLE, MULTIPDB_HOLE
from MDAnalysisTests import (executable_not_found, module_not_found,
tempdir, in_dir)
Copy link
Member

Choose a reason for hiding this comment

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

import order is

  1. python std library
  2. external packages like numpy/pandas/...
  3. mdanalysis specific packages
  4. testing specific packages


from numpy.testing import (TestCase, dec,
assert_equal, assert_almost_equal,
from MDAnalysisTests import (executable_not_found, tempdir, in_dir)
Copy link
Member

Choose a reason for hiding this comment

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

please remove the tempdir dependency

for ts in cls.universe.trajectory[cls.start:cls.stop]]
@pytest.fixture()
def H(self, universe):
with tempdir.in_tempdir():
Copy link
Member

Choose a reason for hiding this comment

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

use a tmpdir_factory here

class TestHOLE(TestCase):
filename = PDB_HOLE

@dec.skipif(executable_not_found("hole"), msg="Test skipped because HOLE not found")
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.

should be a fixture

@utkbansal utkbansal changed the title [WIP]Pytest Style analysis/test_hole.py Pytest Style analysis/test_hole.py Jul 25, 2017
@utkbansal
Copy link
Member Author

@kain88-de Anything else?

@dec.skipif(executable_not_found("hole"), msg="Test skipped because HOLE not found")
def setUp(self):

@pytest.fixture()
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be a static method for pytest to work?

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 don't think so. I can move filename = PDB_HOLE to the fixture though and make it a staticmethod.

Copy link
Member

Choose a reason for hiding this comment

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

so far you made all fixtures in a class static. I was wondering why this isn't necessary here.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kain88-de I sometimes need to access self from within the fixture. That is when I don't make it static.

@kain88-de kain88-de merged commit 5672a7a into MDAnalysis:develop Jul 26, 2017
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.

2 participants