Skip to content

Commit 01878b6

Browse files
authored
Merge pull request astropy#407 from drdavella/fix-test-warnings
Fix pytest warnings related to explicit use of test fixture
2 parents 123c87d + cacf761 commit 01878b6

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

‎astropy_helpers/tests/__init__.py‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,7 @@ def reset_distutils_log():
125125
"""
126126

127127

128-
@pytest.fixture
129-
def testpackage(tmpdir, version='0.1'):
130-
"""
131-
This fixture creates a simplified package called _astropy_helpers_test_
132-
used primarily for testing ah_boostrap, but without using the
133-
astropy_helpers package directly and getting it confused with the
134-
astropy_helpers package already under test.
135-
"""
128+
def create_testpackage(tmpdir, version='0.1'):
136129

137130
source = tmpdir.mkdir('testpkg')
138131

@@ -151,6 +144,18 @@ def testpackage(tmpdir, version='0.1'):
151144
return source
152145

153146

147+
@pytest.fixture
148+
def testpackage(tmpdir, version='0.1'):
149+
"""
150+
This fixture creates a simplified package called _astropy_helpers_test_
151+
used primarily for testing ah_boostrap, but without using the
152+
astropy_helpers package directly and getting it confused with the
153+
astropy_helpers package already under test.
154+
"""
155+
156+
return create_testpackage(tmpdir, version=version)
157+
158+
154159
def cleanup_import(package_name):
155160
"""Remove all references to package_name from sys.modules"""
156161

‎astropy_helpers/tests/test_ah_bootstrap.py‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import pytest
1313

1414
from . import reset_setup_helpers, reset_distutils_log # noqa
15-
from . import run_cmd, run_setup, testpackage
15+
from . import run_cmd, run_setup, testpackage, create_testpackage
1616
from ..utils import silence
1717

1818

@@ -366,9 +366,7 @@ def find_packages(self, requirement):
366366

367367

368368
def test_upgrade(tmpdir, capsys):
369-
# Run the testpackage fixture manually, since we use it multiple times in
370-
# this test to make different versions of _astropy_helpers_test_
371-
orig_dir = testpackage(tmpdir.mkdir('orig'))
369+
orig_dir = create_testpackage(tmpdir.mkdir('orig'))
372370

373371
# Make a test package that uses _astropy_helpers_test_
374372
source = tmpdir.mkdir('source')
@@ -391,8 +389,8 @@ def test_upgrade(tmpdir, capsys):
391389
# Make additional "upgrade" versions of the _astropy_helpers_test_
392390
# package--one of them is version 0.2 and the other is version 0.1.1. The
393391
# auto-upgrade should ignore version 0.2 but use version 0.1.1.
394-
upgrade_dir_1 = testpackage(tmpdir.mkdir('upgrade_1'), version='0.2')
395-
upgrade_dir_2 = testpackage(tmpdir.mkdir('upgrade_2'), version='0.1.1')
392+
upgrade_dir_1 = create_testpackage(tmpdir.mkdir('upgrade_1'), version='0.2')
393+
upgrade_dir_2 = create_testpackage(tmpdir.mkdir('upgrade_2'), version='0.1.1')
396394

397395
dists = []
398396
# For each upgrade package go ahead and build a source distribution of it

0 commit comments

Comments
 (0)