Debian Codegraph @

tests/conftest.py

raw
1 from textwrap import dedent
2 from glob import glob
3 from pathlib import Path
4
5 import pytest
6
7 # grab all files from fixtures/
8 pytest_plugins = [
9 f'fixtures.{fi.stem}' for fi in Path(__file__).glob("fixtures/*.py") if fi.stem != '__init__'
10 ]
11
12 # prevent any test from running if the default .cvdupdate directory already exists
13 @pytest.fixture(scope='session', autouse=True)
14 def fail_if_cvdupdate_dir_exists():
15 defaultdir = Path.home() / '.cvdupdate'
16 if defaultdir.exists():
17 pytest.exit(dedent(f'''
18 Error: {defaultdir} exists.
19 Aborting tests to prevent losing actual cvdupdate data.
20 Ensure tests are not running against an actual cvdupdate install.
21 '''),
22 returncode=1
23 )
24