user1
user1

Reputation: 107

What does pytest-runner do?

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

Answers (2)

Kevin Ding
Kevin Ding

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:

  1. put a setup.py in your source codes directory setup.py used by packing tools

  2. 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

  3. 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
  1. 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

Akhil Lawrence
Akhil Lawrence

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

Related Questions