Top "Pytest" questions

Simple powerful no-boilerplate testing with Python.

how to share a variable across modules for all tests in py.test

I have multiple tests run by py.test that are located in multiple classes in multiple files. What is the …

python unit-testing testing global-variables pytest
Importing correctly with pytest

I just got set up to use pytest with Python 2.6. It has worked well so far with the exception of …

python import pytest
py.test: error: unrecognized arguments: --cov=ner_brands --cov-report=term-missing --cov-config

when I am trying to run my test through command line py.test file_name.py I got this error: …

python pytest
Testing class methods with pytest

In the documentation of pytest various examples for test cases are listed. Most of them show the test of functions. …

python pytest
py.test skips test class if constructor is defined

I have following unittest code running via py.test. Mere presence of the constructor make the entire class skip when …

python pytest
nose vs pytest - what are the (subjective) differences that should make me pick either?

I've started working on a rather big (multithreaded) Python project, with loads of (unit)tests. The most important problem there …

python pytest nose
Async fixtures with pytest

How do I define async fixtures and use them in async tests? The following code, all in the same file, …

python-3.x pytest python-asyncio pytest-aiohttp pytest-asyncio
How can I repeat each test multiple times in a py.test run?

I want to run each selected py.test item an arbitrary number of times, sequentially. I don't see any standard …

python pytest
py.test: how to get the current test's name from the setup method?

I am using py.test and wonder if/how it is possible to retrieve the name of the currently executed …

python pytest
Test discovery failure when tests in different directories are called the same

Using py.test, two tests called the same in different directory causes py.test to fail. Why is that? How …

python unit-testing pytest autodiscovery