Can tests with pytest fixtures be run interactively?
You can bypass the pytest.fixture decorator and directly call the wrapped test function.
tmp = tt.temp_dir.__pytest_wrapped__.obj(request=...)
Accessing internals, it's bad, but when you need it...
Yes. You don't have to manually assemble any test fixtures or anything like that. Everything runs just like calling pytest
in the project directory.
Method1:
This is the best method because it gives you access to the debugger if your test fails
In ipython
shell use:
**ipython**> run -m pytest prj/
This will run all your tests in the prj/tests
directory.
This will give you access to the debugger, or allow you to set breakpoints
if you have a
import ipdb; ipdb.set_trace()
in your program (https://docs.pytest.org/en/latest/usage.html#setting-breakpoints).
Method2:
Use !pytest
while in the test directory. This wont give you access to the debugger. However, if you use
**ipython**> !pytest --pdb
If you have a test failure, it will drop you into the debugger (subshell), so you can run your post-mortem analysis (https://docs.pytest.org/en/latest/usage.html#dropping-to-pdb-python-debugger-on-failures)
Using these methods you can even run individual modules/test_fuctions/TestClasses in ipython
using (https://docs.pytest.org/en/latest/usage.html#specifying-tests-selecting-tests)
**ipython**> run -m pytest prj/tests/test_module1.py::TestClass1::test_function1