-
Notifications
You must be signed in to change notification settings - Fork 519
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
Move tests to pytest #588
Move tests to pytest #588
Conversation
|
ff8b400
to
de789c3
Compare
@kloczek thanks- the Python PATH mess on Windows to get it to find the right version of the script is a lot harder to untangle (which is why it was using module-style invocation in CI in the first place) that on Linux/MacOS... I did change the Windows CI invocation to use |
d091b81
to
ed36ccf
Compare
* custom pytest collector and item to surface pyyaml data-driven tests as individual pytest unit tests * moved some true unit tests to pytest-native tests * deprecated `setup.py test` custom command * updated Makefile to use pytest * align test matrix with planned 7.x Python support
ed36ccf
to
a98fd60
Compare
When I run the tests with one of the following commands:
I get the following error:
Or if I install pyyaml as a system package, it tests that code instead. I'm on a fresh openSUSE Tumbeweed container. What helps:
or adding a pytest.ini:
I didn't realize that yesterday because I was testing in a container that had pyyaml installed, so the tests just passed and I didn't realize it wasn't testing the code from git. |
Also,
See #763 |
Please do not use pytest that way. |
@kloczek
So you can see I tried |
I know what you've done. |
@perlpunk there's no fundamental problem with running just So, there are 2 mechanisms implemented to prevent testing a non-installed Git checkout directly. It is recommended to always test “as installed”. This means, making sure that the project modules aren't imported from a Git checkout, because that's not what the end-users would get. Sometimes, projects forget to include some files into PyPI-published package distributions, causing the CI to be green while the Using tools like
If, for some reason, you don't want to use But again, I encourage you to use Hope that helps! |
My question is still the same: Should it be possible to just run |
Sort of; ultimately pytest has to be able to import the code-under-test, and you don't usually want to bake assumptions about how it should do that into the tests themselves- I'm guessing that's the part you're having trouble with. With pure-Python code that's directly runnable from the source, it's usually sufficient to just have the dir containing the project's packages on The other consideration with all this stuff is that it should usually be done in some kind of isolated Python environment (eg not This is also one of many reasons why the root
Directly invoking the tools as modules from a specific interpreter path ensures that everything is always happening in the same environment; using script wrappers for tools from |
setup.py test
custom command