Reputation: 107
I've written tests in pytest and run them using pytest command. I was looking at other pytest modules and came across pytest-runner. What does this do exactly?
Module's description below, please explain...
Setup scripts can use pytest-runner to add setup.py test support for pytest runner.
Upvotes: 5
Views: 5351
Reputation: 814
at first place, you write you test code and some test support libraries, push them to the git repository.
but, some days later, you may be thinking why don't I pack them to a distribution , upload to a private PyPi site, so every one can download your test support libraries and testcases by pip install xxx command.
before you share your codes as a distribution which can be installed by pip, you will think I need test them.
So, you need put your test code in the directory, then you need a convenient way to run them, for example, run test cases in the directory.
so, the commands is following:
put a setup.py in your source codes directory setup.py used by packing tools
before you pack your code to distribution file , you want to test them with pytest-runner, you can just type the following command to run test
python setup.py pytest
you get your test report, everything is ok, you need pack them up
python setup.py sdist
you will have a .tar.gz file in your dist sub dir
4.you upload it to PyPi.org(of course ,you need register a account)
python setup.py upload dist/xxxx.tar.gz
then, everyone can use your code by
pip install
more than that, you can configure setup.py file ,give your code a executable entry point, so that you can run your test directly by command after installing your distribution
Upvotes: 1
Reputation: 434
This is to enable support for running test cases using setup.py
After installing pytest-runner
you can run test cases using python setup.py pytest
To know more read Building and Distributing packages with setuptoole
Upvotes: 5