So far, the tests rely on the Nose framework. Nose provides both a smart test runner, and some utility functions t write the tests. However, Nose is not maintained any more, and therefore is deprecated. Continuing to use Nose is not sustainable.
This pull request port the complete test suite from Nose to the still maintained Pytest. The port is made in two steps:
in the first step, I made the minimum changes needed to have the tests running on pytest; this includes updating the documentation, the install, and travis
in a second step, I updated the tests to use the idioms recommended by pytest.
Here is a brief summary of the main pytest idioms:
raw assert instead of specialized assert functions: nose, so as the unittest library from the standard library, encourages the use of specialized assert functions. The semantics added in these specialized functions allows more informative error messages compared to raw asserts. Pytest, instead, rewrites the bytecode of each assert call to adapt it to the context.
fixtures: instead of setup and tear down, pytest uses "fixtures". Fixtures are functions that produce a resource. That resource can be attached to a given scope (module, class, function), the scope by default being the function/method. To have access to a resource, a test must have an argument with the same name as the fixture. One benefit of fixtures compared to set up / tear down is an greater flexibility. Indeed, not all the test in a given scope require the same resources; with a setup approach, all common resources are built in the setup even for tests that do not require them all. Fixture are created on demand, only for the tests that require them.
tmpdir: one built-in fixture of pytest is the tmpdir fixture. This fixture creates a temporary directory that lives for the duration of a test.
parametrized tests: one last magic of pytest is the ability to "parametrize" tests. These tests have a list of parameters attached to them and will run for each element of that list. This allows to separate the logic of the tests from the data, but also to limit the code of a test to the strict minimum since the all part about looping over multiple set of parameters is moved out of the test, and it allows to have each parameter run separately giving more granularity to the output. This replaces the test generators of nose that we were not using.
There are some additional magic in pytest that I did not described here. See the website for more.
Finally, a preliminary step was required for the tests to pass. Ghostscript was not available in the latest travis run, likely due to some update. Because of this, all the tests involving weblogo were failing. I added ghostscript to the package to install using apt. I also removed cabal and haskell from the install as they were not needed anymore since pandoc is installed from a deb package. Latter on, it may be worth trying to install pandoc from apt as travis is rolling in a more recent version of ubuntu.
So far, the tests rely on the Nose framework. Nose provides both a smart test runner, and some utility functions t write the tests. However, Nose is not maintained any more, and therefore is deprecated. Continuing to use Nose is not sustainable.
This pull request port the complete test suite from Nose to the still maintained Pytest. The port is made in two steps:
Here is a brief summary of the main pytest idioms:
unittest
library from the standard library, encourages the use of specialized assert functions. The semantics added in these specialized functions allows more informative error messages compared to raw asserts. Pytest, instead, rewrites the bytecode of each assert call to adapt it to the context.tmpdir
fixture. This fixture creates a temporary directory that lives for the duration of a test.There are some additional magic in pytest that I did not described here. See the website for more.
Finally, a preliminary step was required for the tests to pass. Ghostscript was not available in the latest travis run, likely due to some update. Because of this, all the tests involving weblogo were failing. I added ghostscript to the package to install using apt. I also removed cabal and haskell from the install as they were not needed anymore since pandoc is installed from a deb package. Latter on, it may be worth trying to install pandoc from apt as travis is rolling in a more recent version of ubuntu.