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 posargs in tox.ini (single test cases) #145

Closed
tomschr opened this issue Sep 30, 2019 · 0 comments · Fixed by #146
Closed

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

tomschr opened this issue Sep 30, 2019 · 0 comments · Fixed by #146

Comments

@tomschr
Copy link
Member

tomschr commented Sep 30, 2019

Situation

Usually you run tox like this:

tox -e py36

That works, all fine. However, it runs the complete test suite. If you work on a single test function, it is currently not possible to run this alone. You always have to run the complete test suite.

Proposed Solution

I would propose the following small patch to introduce the posargs argument:

diff --git c/tox.ini i/tox.ini
index e172f8a..f7b1b2e 100644
--- c/tox.ini
+++ i/tox.ini
@@ -5,7 +5,7 @@ envlist =
     pypy
 
 [testenv]
-commands = py.test
+commands = py.test {posargs:}

This makes it possible to run tox only for the test function test_should_bump_major:

tox -e py36 test_semver.py::test_should_bump_major

With this single patch, it is even possible to use it for the setup.py script:

python3 setup.py test -a "-e py36 test_semver.py::test_should_bump_major"
tomschr added a commit to tomschr/python-semver that referenced this issue Sep 30, 2019
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
@tomschr tomschr changed the title Improve tox.ini to allow running single test cases add posargs in tox.ini (single test cases) Sep 30, 2019
scls19fr pushed a commit that referenced this issue Oct 1, 2019
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
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 a pull request may close this issue.

1 participant