Skip to content

Commit 8a409e0

Browse files
committed
Splitting up conftest to make both pytest happy and pick up the configuration properly with tox
1 parent a7fc878 commit 8a409e0

2 files changed

Lines changed: 24 additions & 13 deletions

File tree

astroquery/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2+
3+
# Keep the project level fixtures in this file, keeping them in root level
4+
# conftest causes issues with pytest 9.1+
5+
6+
import os
7+
from pathlib import Path
8+
9+
import pytest
10+
11+
12+
@pytest.fixture(scope='function')
13+
def tmp_cwd(tmp_path):
14+
"""Perform test in a pristine temporary working directory."""
15+
old_dir = Path.cwd()
16+
os.chdir(tmp_path)
17+
try:
18+
yield tmp_path
19+
finally:
20+
os.chdir(old_dir)

conftest.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22

3-
import os
4-
from pathlib import Path
3+
# Keep basic config here, so both tox and directly run pytest works as expected.
4+
# Keep the fixtures one layer down for global fixtures and more layer down
5+
# for more specific scopes.
6+
57
import sys
68

79
from astropy.utils import minversion
@@ -59,17 +61,6 @@ def pytest_addoption(parser):
5961
)
6062

6163

62-
@pytest.fixture(scope='function')
63-
def tmp_cwd(tmp_path):
64-
"""Perform test in a pristine temporary working directory."""
65-
old_dir = Path.cwd()
66-
os.chdir(tmp_path)
67-
try:
68-
yield tmp_path
69-
finally:
70-
os.chdir(old_dir)
71-
72-
7364
def pytest_runtestloop(session):
7465
if sys.platform == 'win32':
7566
session.add_marker(pytest.mark.filterwarnings(

0 commit comments

Comments
 (0)