[TIP] Setuptools and pytest integration issue
Laszlo Papp
lpapp at kde.org
Mon Sep 1 09:48:22 PDT 2014
Hi all,
I am having some issues with getting it working correctly.
sudo python setup.py test
running test
running egg_info
writing PyFoo.egg-info/PKG-INFO
writing top-level names to PyFoo.egg-info/top_level.txt
writing dependency_links to PyFoo.egg-info/dependency_links.txt
reading manifest file 'PyFoo.egg-info/SOURCES.txt'
writing manifest file 'PyFoo.egg-info/SOURCES.txt'
running build_ext
==============================================================================================================================
test session starts
===============================================================================================================================
platform linux2 -- Python 2.7.8 -- py-1.4.23 -- pytest-2.6.1
ERROR: file not found: test
================================================================================================================================
in 0.00 seconds
================================================================================================================================
This is the setup.py content that I pretty much copied and pasted over
from the official documentation (*):
import os
import sys
from setuptools.command.test import test as TestCommand
from setuptools import setup
scriptDirectoryPath = os.path.dirname(os.path.realpath(__file__))
exec(open(os.path.join(scriptDirectoryPath, 'pyfoo', 'version.py')).read())
class PyTest(TestCommand):
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = None
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.pytest_args)
sys.exit(errno)
setup(
name='PyFoo',
version=__version__,
long_description=__doc__,
author='Laszlo Papp',
author_email='laszlo.papp at foo.com',
description = ("Python API for Foo."),
url = "http://www.foo.com",
packages=['pyfoo'],
include_package_data=True,
zip_safe=False,
tests_require=['pytest'],
cmdclass = {'test': PyTest},
)
If I pass the "tests" directory to pytest as it can be seen below,
then it works. However, this is neither mentioned in the official
documentation, nor is it something that I would prefer the users to
do.
python setup.py test --pytest-args=tests
Is there a way to just get it automagically working? If yes, is there
something missing from the documentation or I have just overlooked
something simple? Thanks in advance.
Cheers, L.
More information about the testing-in-python
mailing list