Top "Pytest" questions

Simple powerful no-boilerplate testing with Python.

In pytest, what is the use of conftest.py files?

I recently discovered pytest. It seems great. However, I feel the documentation could be better. I'm trying to understand what …

python testing pytest
Run code before and after each test in py.test?

I want to run additional setup and teardown checks before and after each test in my test suite. I've looked …

python testing pytest test-fixture
Logging within pytest tests

I would like to put some logging statements within test function to examine some state variables. I have the following …

python logging pytest
pytest: assert almost equal

How to do assert almost equal with py.test for floats without resorting to something like: assert x - 0.00001 <= …

python unit-testing pytest
How to pass environment variables to pytest

Before I start executing the tests in my Python project, I read some environment variables and set some variables with …

pytest
How to mock a readonly property with mock?

How do you mock a readonly property with mock? I tried: setattr(obj.__class__, 'property_to_be_mocked', mock.Mock()) …

python unit-testing mocking pytest
How to run unittest discover from "python setup.py test"?

I'm trying to figure out how to get python setup.py test to run the equivalent of python -m unittest …

python unit-testing nose pytest unittest2
How to pass arguments in pytest by command line

I have a code and I need to pass the arguments like name from terminal. Here is my code and …

python pytest
How to tell py.test to skip certain directories?

I tried to use the norecursedirs option inside setup.cfg to tell py.test not to collect tests from certain …

python unit-testing pytest
How to use pytest to check that Error is NOT raised

Let's assume we have smth like that : import py, pytest ERROR1 = ' --- Error : value < 5! ---' ERROR2 = ' --- …

python pytest raise