diff --git a/doc/en/goodpractises.txt b/doc/en/goodpractises.txt index 962148705..01e0bbbd4 100644 --- a/doc/en/goodpractises.txt +++ b/doc/en/goodpractises.txt @@ -1,4 +1,3 @@ - .. highlightlang:: python .. _`goodpractises`: @@ -190,12 +189,16 @@ this to your ``setup.py`` file:: user_options = [] def initialize_options(self): pass + def finalize_options(self): pass + def run(self): import sys,subprocess errno = subprocess.call([sys.executable, 'runtests.py']) raise SystemExit(errno) + + setup( #..., cmdclass = {'test': PyTest}, @@ -220,20 +223,24 @@ Setuptools supports writing our own Test command for invoking pytest. Most often it is better to use tox_ instead, but here is how you can get started with setuptools integration:: - from setuptools.command.test import test as TestCommand import sys + from setuptools.command.test import test as TestCommand + + class PyTest(TestCommand): def finalize_options(self): TestCommand.finalize_options(self) self.test_args = [] self.test_suite = True + def run_tests(self): #import here, cause outside the eggs aren't loaded import pytest errno = pytest.main(self.test_args) sys.exit(errno) + setup( #..., tests_require=['pytest'],