Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Teamcity pytest plugin & unit test reporting

We have recently moved away from our custom test runner / discovery tool in favor of py.test. For proper unit test reporting when running under teamcity there exists a pytest plugin: https://github.com/JetBrains/teamcity-python

When installed with:

python setup.py install

The plugin is discovered correctly by pytest. However, we don't want to install pytest & this plugin on our build machines. Instead we would rather have them packaged as part of our projects "tools" directory.

How do install / configure py.test to "discover" this plugin. We have tried adding pytest_plugins = "teamcity" with several variations to the setup.cfg file of pytest with no success.

like image 492
Jesse Avatar asked Feb 09 '13 03:02

Jesse


1 Answers

There is no "pytest_plugins" configuration variable (see output at the end of "py.test -h). However, the env var "PYTEST_PLUGINS" contains comma-separated python import paths. So if you plugin is in "teamcity/util/myplugin.py" you would set it like this:

export PYTEST_PLUGINS=teamcity.util.myplugin

You can also use a command line option "-p teamcity.util.myplugin" to achieve a similar effect. And then add it to your setup.cfg's section:

[pytest]
addopts = -p teamcity.util.myplugin
like image 127
hpk42 Avatar answered Oct 21 '22 15:10

hpk42