Skip to content
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

Add a tox.ini that doesn't depend on setup.py test #368

Merged
merged 2 commits into from
Oct 23, 2016

Conversation

danilobellini
Copy link
Collaborator

Abstract

  • Update tox.ini to avoid the setup.py test command that installs pytest-timeout twice instead of pytest

  • Include more CPython versions: 3.2, 3.3, 3.5 and 3.6

  • Include PyPy3

  • Add {posargs} so one can test selected environments passing parameters to py.test (arguments after --), e.g.

    tox -e py35,py34 -- -k test_inotify
    

Description

I wasn't able to run the watchdog test suite before due to the fact that pytest was installing pytest-timeout twice. This used to be the tox -e py27 result:

[...]
py27 installed: argh==0.26.2,pathtools==0.1.2,PyYAML==3.11,watchdog==0.8.3
py27 runtests: PYTHONHASHSEED='3431958763'
py27 runtests: commands[0] | python setup.py test
[...]

It installs pytest-timeout:

[...]
Searching for pytest-timeout>=0.3
Reading https://pypi.python.org/simple/pytest-timeout/
Downloading https://pypi.python.org/packages/cf/92/ab29b9baa54d47dfd50e43be35577de9af4e7ebf27d29f546ddeb6c3b6f5/pytest-timeout-1.0.0.tar.gz#md5=f9f162bd079689980b5614673ddfdae4
Best match: pytest-timeout 1.0.0
Processing pytest-timeout-1.0.0.tar.gz
Writing /tmp/easy_install-jssqbJ/pytest-timeout-1.0.0/setup.cfg
Running pytest-timeout-1.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-jssqbJ/pytest-timeout-1.0.0/egg-dist-tmp-fIEa1U
zip_safe flag not set; analyzing archive contents...
Moving pytest_timeout-1.0.0-py2.7.egg to /home/danilo/code/watchdog/.eggs

Installed /home/danilo/code/watchdog/.eggs/pytest_timeout-1.0.0-py2.7.egg
[...]

But when installing pytest, it installs pytest-timeout again:

[...]
Searching for pytest
Downloading https://pypi.python.org/packages/cf/92/ab29b9baa54d47dfd50e43be35577de9af4e7ebf27d29f546ddeb6c3b6f5/pytest-timeout-1.0.0.tar.gz#md5=f9f162bd079689980b5614673ddfdae4
Best match: pytest timeout-1.0.0
Processing pytest-timeout-1.0.0.tar.gz
Writing /tmp/easy_install-lViTvF/pytest-timeout-1.0.0/setup.cfg
Running pytest-timeout-1.0.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-lViTvF/pytest-timeout-1.0.0/egg-dist-tmp-8MRQkx
zip_safe flag not set; analyzing archive contents...
Removing /home/danilo/code/watchdog/.eggs/pytest_timeout-1.0.0-py2.7.egg
Moving pytest_timeout-1.0.0-py2.7.egg to /home/danilo/code/watchdog/.eggs

Installed /home/danilo/code/watchdog/.eggs/pytest_timeout-1.0.0-py2.7.egg
[...]

Next, the tests doesn't run because pytest wasn't installed:

[...]
Traceback (most recent call last):
  File "setup.py", line 154, in <module>
    zip_safe=False
  File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/danilo/code/watchdog/.tox/py27/lib/python2.7/site-packages/setuptools/command/test.py", line 163, in run
    self.distribution.fetch_build_eggs(self.distribution.tests_require)
  File "/home/danilo/code/watchdog/.tox/py27/lib/python2.7/site-packages/setuptools/dist.py", line 394, in fetch_build_eggs
    replace_conflicting=True,
  File "/home/danilo/code/watchdog/.tox/py27/lib/python2.7/site-packages/pkg_resources/__init__.py", line 829, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pytest' distribution was not found and is required by the application
[...]

The same happened in a virtualenv with Python 3, that has nothing to do with tox:

$ pip list
pip (8.1.2)
setuptools (25.1.6)
wheel (0.29.0)
$ python -V
Python 3.5.2
$ python setup.py test
[...]
Traceback (most recent call last):
  File "setup.py", line 154, in <module>
    zip_safe=False
  File "/usr/lib64/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib64/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/danilo/venv35/lib/python3.5/site-packages/setuptools/command/test.py", line 163, in run
    self.distribution.fetch_build_eggs(self.distribution.tests_require)
  File "/home/danilo/venv35/lib/python3.5/site-packages/setuptools/dist.py", line 394, in fetch_build_eggs
    replace_conflicting=True,
  File "/home/danilo/venv35/lib/python3.5/site-packages/pkg_resources/__init__.py", line 829, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pytest' distribution was not found and is required by the application

And I don't see anything buggy in the setup.py either, it actually runs in my Python 3.2 environment:

$ pip list
coverage (3.7.1)
ipython (1.2.1)
pip (7.1.2)
pluggy (0.3.1)
py (1.4.31)
pytest (2.9.2)
setuptools (25.1.0)
tox (2.3.1)
virtualenv (13.1.2)
wheel (0.29.0)
$ python -V
Python 3.2.6
$ python setup.py test
[...]
==================== 61 passed, 1 skipped in 17.86 seconds =====================

I wanted to test on every environment without manually creating dozens of environments trying pip/setuptools versions (actually, that's why tox exist), and Python 3.2 is hard to test/use nowadays, since pip doesn't support it anymore.

I've changed the tox.ini to make it independent from the setup.py test command, and also to include Python 3.5, 3.6 and PyPy3. To test in Python 3.2, the environment that calls tox must have virtualenv<14 (and pip<8). For the remaining ones, that's not required.

Tox caches downloads and virtualenvs. It allows passing parameters directly to py.test to call. For example,

tox -e py35,py34,pypy3 -- -k test_inotify

Runs the tests on CPython 3.5, CPython 3.4 and PyPy3, always calling py.test -k test_inotify, i.e., only the 5 tests that matches with that name, deselecting the remaining ones.

With this tox.ini I managed to run the entire test suite in every environment:

$ tox
[...]
___________________________________ summary ____________________________________
  py36: commands succeeded
  py35: commands succeeded
  py34: commands succeeded
  py33: commands succeeded
  py32: commands succeeded
  py27: commands succeeded
  py26: commands succeeded
  pypy3: commands succeeded
  pypy: commands succeeded
  congratulations :)

@danilobellini danilobellini force-pushed the tox branch 3 times, most recently from ea2b52d to a513684 Compare August 14, 2016 13:53
@danilobellini
Copy link
Collaborator Author

I don't know why CPython 3.2 (with coverage<4) shows 41% coverage, every other environment shows it correctly (81%). The directory isn't src/watchdog/... but a site-packages directory. This script fix that, if you wish to use coveralls or to have a cleaner coverage report.

@DonyorM
Copy link
Contributor

DonyorM commented Aug 24, 2016

I guess the one question to ask is if we even want to bother testing for python 3.2 anymore, since it isn't well supported. Is it the default install for any setups?

@danilobellini
Copy link
Collaborator Author

I don't know. Perhaps testing with CPython 3.2 without code coverage would make sense. Perhaps keeping only the last stable PyPy3 version (which is a Python 3.2) would be enough. Actually, it doesn't seem to be something about the watchdog code, only about its test suite. As of today, watchdog doesn't require any resource incompatible with Python 3.2. I think it would make more sense to remove compatibility when some used resource require other Python version, as happened with coverage.py when it required the u"unicode prefixed with 'u'", which works in PyPy3 but not in CPython 3.2.

@danilobellini
Copy link
Collaborator Author

The new py.test 3.0 dropped the Python 3.2 compatibility, as it's now using the u-prefixed unicode literals... I can rebase or make a new commit on this PR branch, updating the tox.ini to replace pytest by py32: pytest<3, and that works fine on other environments since the plugins themselves requires pytest. Or should I remove the CPython 3.2 from this PR?

- Included more CPython versions: 3.2, 3.3, 3.5 and 3.6
- Included PyPy3
- Added {posargs} so one can test selected environments passing
  parameters to py.test (arguments after "--"), e.g.
  tox -e py35,py34 -- -k test_inotify
- Coverage linked to the package, not to the directory
- Travis builds runs tox instead of "python setup.py test"; the
  latter was breaking on CPython 3.2
- Add jobs for the PyPy3, CPython 3.5 and CPython 3.6 (nightly)
  interpreters
- Jobs running CPython 3.6 (nightly) are allowed to fail without
  failing the whole build
@danilobellini
Copy link
Collaborator Author

Rebased to use py.test < 3 on CPython 3.2. I can change it afterwards, if required.

@danilobellini
Copy link
Collaborator Author

I can amend/rebase this to put CPython 3.2 as allowed to fail in Travis, if required/desired.

@danilobellini
Copy link
Collaborator Author

Now the Travis nightly build is Python 3.7. Should I add a specific Python 3.6 Travis environment and explicitly include Python 3.7 on tox.ini?

If this won't ever be merged, please tell me. Is this project dead?

@DonyorM
Copy link
Contributor

DonyorM commented Oct 23, 2016

Project's not fully dead, I got contributor status by contacting the maintainer by email. Not sure if I should have received it, I had something I wanted to add and couldn't get anyone to pay attention to my PR.

Unfortunately, I don't fully understand the whole project. However, this seems a good addition, so I'll merge it.

@DonyorM DonyorM merged commit 174f25e into gorakhargosh:master Oct 23, 2016
CCP-Aporia pushed a commit to CCP-Aporia/watchdog that referenced this pull request Aug 13, 2020
Add a tox.ini that doesn't depend on setup.py test
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

Successfully merging this pull request may close these issues.

2 participants