Port auxiliary module to pytest #1439
Conversation
@kain88-de @richardjgowers Have a look at this. |
@utkbansal it looks like you might have to turn I wouldn't blindly put everything from |
I'm guessing, the error is arising because |
@richardjgowers Okay, I'll try that. Interesting to note that the |
@@ -34,14 +37,17 @@ def test_get_bad_auxreader_format_raises_ValueError(): | |||
# should raise a ValueError when no AuxReaders with match the specified format | |||
mda.auxiliary.core.get_auxreader_for(format='bad-format') | |||
|
|||
class BaseAuxReference(object): | |||
class BaseAuxReference(TestCase): |
kain88-de
Jun 27, 2017
Member
this contains reference data. No need to declare it as a test class
this contains reference data. No need to declare it as a test class
@@ -33,8 +33,11 @@ | |||
from MDAnalysisTests.auxiliary.base import (BaseAuxReaderTest, BaseAuxReference) | |||
|
|||
class XVGReference(BaseAuxReference): | |||
def __init__(self): |
kain88-de
Jun 27, 2017
Member
these are normal classes.
these are normal classes.
@kain88-de @richardjgowers I have made some progress. I still have 3 test cases failing. I'm looking into that. A quick review would be helpful. basically what I want to know is - if this the direction we want to proceed in? |
Got those errors, apparently having the scope set to |
Don't worry about scope yet, that's an optimisation |
This should fix the drop in coverage. I still have to do some cleanup stuff. |
@utkbansal. There is a possible minimal fix in #1440. You can just take the code. No need for commit attribution. Choose better names though! Simply doing the init/setup in a different named method fixes everything. As long as coverage doesn't drop this is OK for now but should be fixed with a better solution long term. |
@kain88-de @richardjgowers All green and no drop in coverage! Have cleaned this up. Please review. |
Looks good |
def test_changing_n_col_raises_ValueError(self): | ||
@staticmethod | ||
@pytest.fixture() | ||
def ref(): |
kain88-de
Jun 27, 2017
Member
what happens when I define a global fixture ref
in the same file?
what happens when I define a global fixture ref
in the same file?
utkbansal
Jun 27, 2017
Author
Member
I tried making both of them global. 3 tests failed. So I switched back.
I tried making both of them global. 3 tests failed. So I switched back.
kain88-de
Jun 27, 2017
Member
So if I now create a global fixture the tests will break?
So if I now create a global fixture the tests will break?
def reader(ref): | ||
return ref.reader(ref.testdata, initial_time=ref.initial_time, | ||
dt=ref.dt, auxname=ref.name, | ||
time_selector=None, data_selector=None) |
kain88-de
Jun 27, 2017
Member
indentation
indentation
@richardjgowers Should be ready to be merged now. |
Can someone explain why Looks like a bug. |
Looks like a mistake. You can rename the functions. |
|
||
def test_xvg_bz2(): | ||
reader = mda.auxiliary.XVG.XVGReader(XVG_BZ2) | ||
assert_array_equal(reader.read_all_times(), np.array([0., 50., 100.])) | ||
|
||
|
||
def test_xvg_bz2(): |
kain88-de
Jun 28, 2017
Member
If you rename the function so that the test is run as well the PR is good to go.
If you rename the function so that the test is run as well the PR is good to go.
@richardjgowers @kain88-de Can be merged now! |
Another one down! |
Fixes #
Changes made in this Pull Request:
PR Checklist