Skip to content

Fix #145: add posargs in tox.ini (single test cases) #146

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

Merged
merged 5 commits into from
Oct 1, 2019

Conversation

tomschr
Copy link
Member

@tomschr tomschr commented Sep 30, 2019

This PR fixes #145

Without the posargs argument tox has to run the complete test suite. With this patch, you can
pass a test file and a test function. That allows tox to only run this specific test function. For example:

$ tox -e py36 test_semver.py::test_should_bump_major

Keep in mind, it doesn't change the default behavior. It's just an additional feature if someone wants to run a single test function alone.

This may help to speed up the development a little bit. 😉

Without the posargs argument tox has to run the
*complete* test suite. With this patch, you can
pass a test file and a test function. That allows tox
to only run this specific test function. For example:

$ tox -e py36 test_semver.py::test_should_bump_major
@s-celles
Copy link
Member

s-celles commented Oct 1, 2019

Most of builds was broken. CI triggered again.

@s-celles
Copy link
Member

s-celles commented Oct 1, 2019

Builds still failing

The old spelling py.test will be deprecated in the future.
@ppkt
Copy link
Member

ppkt commented Oct 1, 2019

I believe it's caused by invoking tests by python setup.py test in Travis CI. Running them just by running tox works fine. Furthermore, it seems that using tox in setup.py is discouraged: https://tox.readthedocs.io/en/latest/example/basic.html#integration-with-setup-py-test-command

@tomschr
Copy link
Member Author

tomschr commented Oct 1, 2019

Hmn, this is strange. Seems there is a difference between the run with python setup.py test and tox.

I've try a different approach now.

@tomschr
Copy link
Member Author

tomschr commented Oct 1, 2019

@ppkt Ha, we almost posted at the same time with the same idea. 😆

I've replaced the call of python setup.py test with tox -v. Seems to work now. 😉

This make consecutive calls a bit faster
@tomschr
Copy link
Member Author

tomschr commented Oct 1, 2019

I've also added a second line with caching pip dependencies. I think this is useful and described in https://docs.travis-ci.com/user/caching
The cache is stored on Travis in $HOME/.cache/pip.

@tomschr
Copy link
Member Author

tomschr commented Oct 1, 2019

Oh, just another stupid comment before I forget: Please adjust the commit message when you squash the commits. I think it deviated a bit from the original idea.

I would suggest to use something like this (adjust it to your needs):

Fix #146: improve tox.ini/.travis.yml

* Changes in tox.ini:
  * add posargs for pytest. This allows to run only a single test function.
  * Rename py.test -> pytest as the old spelling py.test will be deprecated in the future.

* Changes in .travis.yml:
  * Add cache for pip to speed up things a little bit
  * Add tox as a installation requirement
  * Replace setup.py with tox as it discouraged in https://tox.readthedocs.io/en/latest/example/basic.html#integration-with-setup-py-test-command

@s-celles s-celles merged commit f60e11c into python-semver:master Oct 1, 2019
@s-celles
Copy link
Member

s-celles commented Oct 1, 2019

Thanks again @tomschr for your contribution

@tomschr tomschr deleted the feature/145-tox-add-posargs branch October 2, 2019 13:43
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.

add posargs in tox.ini (single test cases)
3 participants