I want to start writing unit tests for my Python code, and the py.test framework sounds like a better bet than Python’s bundled unittest. So I added a “tests”...
I am using selenium for end to end testing and I can’t get how to use setup_class and teardown_class methods. I need to set up browser in setup_class method,...
I am using py.test to test some DLL code wrapped in a python class MyTester. For validating purpose I need to log some test data during the tests and...
I am working on a package in Python. I use virtualenv. I set the path to the root of the module in a .pth path in my virtualenv, so...
How to do assert almost equal with py.test for floats without resorting to something like: assert x - 0.00001 <= y <= x + 0.00001 More specifically it will...
I used easy_install to install pytest on a mac and started writing tests for a project with a file structure likes so: repo/ |--app.py |--settings.py |--models.py |--tests/ |--test_app.py run...
I’m trying to use TDD (test-driven development) with pytest. pytest will not print to the console when I use print. I am using pytest my_tests.py to run it. The...
I recently discovered pytest. It seems great. However, I feel the documentation could be better. I’m trying to understand what conftest.py files are meant to be used for. In...
Is there a way to select pytest tests to run from a file? For example, a file foo.txt containing a list of tests to be executed: tests_directory/foo.py::test_001 tests_directory/bar.py::test_some_other_test Or,...
Code: # coding=utf-8 import pytest def whatever(): return 9/0 def test_whatever(): try: whatever() except ZeroDivisionError as exc: pytest.fail(exc, pytrace=True) Output: ================================ test session starts ================================= platform linux2 -- Python...