-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Writing tests against testdir.runpytest() and local plugin (no tox) #47
Comments
Just reporting a little bit of progress with this, the following test loads the plugin via args into def test_mix_of_checks_and_asserts_are_reported_ok(testdir):
testdir.makepyfile(
"""
from pytest_check import check
def test_foo():
with check:
assert 4 == 5
def test_mix():
with check:
assert 1 == 2
# assert 2 == 3
"""
)
result = testdir.runpytest('--trace-config', '-ppytest_check')
result.assert_outcomes(failed=2, passed=0)
Outputs:
The output of the embedded run appears to be a clue: "2 passed in 0.02s" (should be two failed). |
@lhayhurst Could you include the top header with versions?
|
@lhayhurst Also, do you have your local version of pytest-check installed while running the tests? tox will create a new virtual env, then install the local pytest-check package, then run tests. After creating a new virtual environment, from the pytest-check directory, I do my pip list and pip freeze looks like this:
|
Hi, I'm pytest 6.2.1 and Python 3.7. I do not pip install local version of pytest-check installed when running the tests -- I'll try that now. |
That did the trick! Thank you! Also, when I made this change to confest.py's if report.longrepr:
report.longrepr.append("\n".join(longrepr))
else:
report.longrepr = "\n".join(longrepr) Feel free to close this ticket out, appreciate your time (and the excellent book!). |
The longrepr trick doesn't work on newer versions of pytest. |
Hi, I found this project after reading your great Python Testing With Python Book.
After downloading the project locally, I was able to run tox and have all the tests pass. However, when I try to run the tests using a local python3 instance (I'm using an activated conda env), the "integration" style tests that inject in python scripts using the
testdir
fixture all fail.For example, I wrote this test trying to reproduce #43 and #44:
When using a local (non tox) pytest (in my case, in the conda envir
./envs/default/bin
), for exThe trace-config output shows me that the
pytest-check
fixture is being loaded, but the figure isn't being loaded in the test run viatestdir.runpytest
. Can I get any of the tests that usetestdir
to pass without using tox, and instead use a project-local pytest instance running via the command line?Thank you!
The text was updated successfully, but these errors were encountered: