← 输入框|github.com|刷新
Skip to content

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

Merged
s-celles merged 5 commits into
python-semver:masterfrom
tomschr:feature/145-tox-add-posargs
Oct 1, 2019
Merged

s-celles merged 5 commits into
python-semver:masterfrom
tomschr:feature/145-tox-add-posargs

Conversation

@tomschr

@tomschr tomschr commented Sep 30, 2019

Copy link
Copy Markdown
Member

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

s-celles commented Oct 1, 2019

Copy link
Copy Markdown
Member

Most of builds was broken. CI triggered again.

@s-celles

s-celles commented Oct 1, 2019

Copy link
Copy Markdown
Member

Builds still failing

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

ppkt commented Oct 1, 2019

Copy link
Copy Markdown
Member

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

tomschr commented Oct 1, 2019 •

Copy link
Copy Markdown
Member Author

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

tomschr commented Oct 1, 2019 •

Copy link
Copy Markdown
Member Author

@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

tomschr commented Oct 1, 2019

Copy link
Copy Markdown
Member Author

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

tomschr commented Oct 1, 2019

Copy link
Copy Markdown
Member Author

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

s-celles commented Oct 1, 2019

Copy link
Copy Markdown
Member

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