Introduce parameterized pytest suite #91
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Commit message
This creates an alternative test suite using the wonderful pytest
and parameterizing over 400 names off into json storage. It is
intended to include all functionality of the existing test suite,
while also:
A note on Travis
This build will fail because Travis appears to have dropped support or moved archives for Pythons 2.6, 3.2, and 3.3. E.g. just now:
These tests are passing on every Python version that Travis is successfully downloading.
Pytest
Most of the work here was simply reformatting tests into pytest, then refactoring out the data from repeated test functions into json files. There are a few other changes here and there, but I tried not to add too many unnecessary changes.
For those unfamiliar with pytest, as a simple example of the transformation take these two:
Translated into pytest -- with little more than a regex substitution -- they become:
Which is fine, but the true special sauce to actually improve the test suite is using pytest to transform a sequence of things being run in a test into a sequence of identical tests run on each thing:
And now it's incredibly easy to add a hundred more. Anywhere there was a loop inside a test to make repeat assertions, there can instead be a series of tests.
Additional notes
I read through the discussion of the 2017 proposal at #61 before working this through. I believe that this overhaul will satisfy the stated desire for a more nuanced test strategy without the downsides identified in the previous approach.
I didn't want to change support, so allowing Python 2.6 (!) means pinning to pytest v3.3. They dropped support for Python 2.7 and 3.4 with pytest v4.6 (see https://docs.pytest.org/en/latest/py27-py34-deprecation.html).
This is pretty substantial, so of course I'm expecting to have some discussion and changes.