Skip to content

Setuptools integration example does not work anymore #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
danijar opened this issue Nov 29, 2015 · 2 comments
Closed

Setuptools integration example does not work anymore #1201

danijar opened this issue Nov 29, 2015 · 2 comments

Comments

@danijar
Copy link

danijar commented Nov 29, 2015

The Good Integration Practices guide includes an example of how to integrate with setuptools. It doesn't work anymore since test_args is now read-only. The problem was also discovered by users of the Marshmallow library, however their fix was to not use setuptools anymore.

import sys

from setuptools.command.test import test as TestCommand


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 = []

    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(
    #...,
    tests_require=['pytest'],
    cmdclass = {'test': PyTest},
    )
Traceback (most recent call last):
  File "setup.py", line 72, in <module>
    cmdclass={'test': TestCommand, 'build_ext': BuildExtCommand},
  File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.5/distutils/dist.py", line 973, in run_command
    cmd_obj.ensure_finalized()
  File "/usr/lib/python3.5/distutils/cmd.py", line 107, in ensure_finalized
    self.finalize_options()
  File "setup.py", line 15, in finalize_options
    self.test_args = []
AttributeError: can't set attribute
@jiffyclub
Copy link

Duplicate of #1134

@nicoddemus
Copy link
Member

Thanks @jiffyclub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants