Merged in graingert/pytest/graingert/pep8-good-practices-code-1394196858258 (pull request #125)
pep8 good practices code
This commit is contained in:
commit
24a458b4c8
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
.. highlightlang:: python
|
.. highlightlang:: python
|
||||||
.. _`goodpractises`:
|
.. _`goodpractises`:
|
||||||
|
|
||||||
|
@ -190,12 +189,16 @@ this to your ``setup.py`` file::
|
||||||
user_options = []
|
user_options = []
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
import sys,subprocess
|
import sys,subprocess
|
||||||
errno = subprocess.call([sys.executable, 'runtests.py'])
|
errno = subprocess.call([sys.executable, 'runtests.py'])
|
||||||
raise SystemExit(errno)
|
raise SystemExit(errno)
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
#...,
|
#...,
|
||||||
cmdclass = {'test': PyTest},
|
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
|
Most often it is better to use tox_ instead, but here is how you can
|
||||||
get started with setuptools integration::
|
get started with setuptools integration::
|
||||||
|
|
||||||
from setuptools.command.test import test as TestCommand
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from setuptools.command.test import test as TestCommand
|
||||||
|
|
||||||
|
|
||||||
class PyTest(TestCommand):
|
class PyTest(TestCommand):
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
TestCommand.finalize_options(self)
|
TestCommand.finalize_options(self)
|
||||||
self.test_args = []
|
self.test_args = []
|
||||||
self.test_suite = True
|
self.test_suite = True
|
||||||
|
|
||||||
def run_tests(self):
|
def run_tests(self):
|
||||||
#import here, cause outside the eggs aren't loaded
|
#import here, cause outside the eggs aren't loaded
|
||||||
import pytest
|
import pytest
|
||||||
errno = pytest.main(self.test_args)
|
errno = pytest.main(self.test_args)
|
||||||
sys.exit(errno)
|
sys.exit(errno)
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
#...,
|
#...,
|
||||||
tests_require=['pytest'],
|
tests_require=['pytest'],
|
||||||
|
|
Loading…
Reference in New Issue