Package: pytest-reqs
DescriptionThis plugin checks your requirements files for specific versions, and compares
those versions with the installed libraries in your environment, failing your
test suite if any are invalid or out of date.This is useful for keeping virtual environments up-to-date, and ensuring that
your test suite is always being passed with the requirements you have
specified.It also has the added bonus of verifying that your requirements files are
syntatically valid, and can check if there are new releases of your
dependencies available.Usageinstall via:pip install pytest-reqsif you then type:py.test --reqsby default it will search for dependencies in the files matching:req*.txtreq*.piprequirements/*.txtrequirements/*.pipand the declared dependencies will be checked against the current environment.A little exampleIf your environment has dependencies installed like this:$ pip freeze
foo==0.9.9But you have arequirements.txtfile like this:$ cat requirements.txt
foo==1.0.0you can runpy.testwith the plugin installed:$ py.test --reqs
=================================== FAILURES ===================================
______________________________ requirements-check ______________________________
Distribution "foo" requires foo==1.0.0 (from -r requirements.txt (line 1)) but
0.9.9 is installedIt also handlespip’s version containment syntax (e.g,foo<=1.0.0,foo>=1.0.0, etc):$ py.test --reqs
=================================== FAILURES ===================================
______________________________ requirements-check ______________________________
Distribution "foo" requires foo>=1.0.0 (from -r requirements.txt (line 1)) but
0.9.9 is installedFurthermore, it will tell you if your requirements file is invalid (for
example, if there is not enough=symbols):$ py.test --reqs
______________________________ requirements-check ______________________________
Invalid requirement: 'foo=1.0.0' (from -r requirements.txt)Configuring optionsIgnoring local projectsYou might have requirements files with paths to local projects, e.g. for local
development:$ cat requirements/local_development.txt
-e ../fooHowever, testing these requirements will fail if the test environment is
missing the local project (e.g., on a CI build):=================================== FAILURES ===================================
______________________________ requirements-check ______________________________
../foo should either be a path to a local project or a VCS url beginning with
svn+, git+, hg+, or bzr+ (from -r requirements.txt)To get around this, you can disable checking for local projects with the
followingpytestoption:# content of setup.cfg
[pytest]
reqsignorelocal = TrueDeclaring your own filename patternsYou might have requirements files in files other than the default filename
patterns:req*.txtreq*.piprequirements/*.txtrequirements/*.pipWhile there aren’t any restrictions on what filenames are or are not valid for
requirements files, the patterns which are currently supported bypytest-reqsare the same common patterns supported by other automated tools
around requirements files.However, you can override these default patterns with the followingpytestoption:# content of setup.cfg
[pytest]
reqsfilenamepatterns =
    mycustomrequirementsfile.txt
    someotherfilename.extRunningpytest-reqsbefore any other testsCurrently there is no way to define the order of pytest plugins (seepytest-dev/pytest#935)This means that if you don’t use any other plugins,pytest-reqswill run
it’s tests last. If you do use other plugins, there is no way to guarantee when
thepytest-reqstests will be run.If you absolutely need to runpytest-reqsbefore any other tests and
plugins, instead of using the--reqsflag, you can define atests/conftest.pyfile as follows:frompytest_reqsimportcheck_requirementsdefpytest_collection_modifyitems(config,session,items):check_requirements(config,session,items)Running requirements checks and no other testsYou can also restrict your test run to only perform “reqs” tests and not any
other tests by typing:py.test --reqs -m reqsThis will only run test items with the “reqs” marker which this plugin adds
dynamically.Checking for out-of-date dependenciesYou can use the--reqs-outdatedflag to determine if any of your
dependencies are out-of-date:$ py.test --reqs-outdated
______________________________ requirements-check ______________________________
Distribution "foo" is outdated (from -r requirements.txt (line 1)),
latest version is foo==1.0.1This feature is only available withpip>=9.0.0.AuthorsDustin IngramVictor TitorLicenseOpen source MIT license.NotesThe repository of this plugin is athttp://github.com/di/pytest-reqs.For more info on py.test seehttp://pytest.org.