1
0
Fork 0
tqdm/tests/conftest.py
Daniel Baumann 6759e100fe
Merging upstream version 4.66.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-05 19:14:31 +01:00

27 lines
757 B
Python

"""Shared pytest config."""
import sys
from pytest import fixture
from tqdm import tqdm
@fixture(autouse=True)
def pretest_posttest():
"""Fixture for all tests ensuring environment cleanup"""
try:
sys.setswitchinterval(1)
except AttributeError:
sys.setcheckinterval(100) # deprecated
if getattr(tqdm, "_instances", False):
n = len(tqdm._instances)
if n:
tqdm._instances.clear()
raise EnvironmentError(f"{n} `tqdm` instances still in existence PRE-test")
yield
if getattr(tqdm, "_instances", False):
n = len(tqdm._instances)
if n:
tqdm._instances.clear()
raise EnvironmentError(f"{n} `tqdm` instances still in existence POST-test")