From 2b0887fa5f29c847c829354f235fcab7e0460891 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Thu, 15 Mar 2012 15:15:21 +0100 Subject: [PATCH] document integration with setuptools/distribute test command and tests_require --- CHANGELOG | 2 ++ doc/goodpractises.txt | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 276141d79..b44497b7d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,8 @@ Changese between 2.2.3 and ... - fix issue 126: correctly match all invalid xml characters for junitxml binary escape +- document integration with the extended distribute/setuptools test commands + Changes between 2.2.2 and 2.2.3 ---------------------------------------- diff --git a/doc/goodpractises.txt b/doc/goodpractises.txt index c6b61d25e..8e2fb2324 100644 --- a/doc/goodpractises.txt +++ b/doc/goodpractises.txt @@ -94,6 +94,40 @@ options. .. _`test discovery`: .. _`Python test discovery`: + +Integration with setuptools/distribute test commands +---------------------------------------------------- + +Distribute/Setuptools support test requirements, +which means its really easy to extend its test command +to support running a pytest from test requirements:: + + 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 + pytest.main(self.test_args) + + setup( + ..., + tests_require=['pytest'], + cmdclass = {'test': pytest}, + ) + +Now if you run:: + + python setup.py test + +this will download py.test if needed and then run py.test +as you would expect it to. + + Conventions for Python test discovery -------------------------------------------------