Skip to content

Commit

Permalink
Shift unpacking of integration tests config in pytest_configure.
Browse files Browse the repository at this point in the history
  • Loading branch information
Karan Desai committed Jun 5, 2016
1 parent cffa393 commit d6b97f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 14 additions & 14 deletions tardis/tests/tests_slow/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@


def pytest_configure(config):
integration_tests_configpath = config.getvalue("integration-tests")
if integration_tests_configpath is not None:
integration_tests_configpath = os.path.expandvars(
os.path.expanduser(integration_tests_configpath)
)
config.option.integration_tests_config = yaml.load(
open(integration_tests_configpath))

# A common tempdir for storing plots / PDFs and other slow test related data
# generated during execution.
tempdir_session = tempfile.mkdtemp()
Expand Down Expand Up @@ -47,13 +55,12 @@ def pytest_unconfigure(config):
# These steps are already performed by `integration_tests_config` but
# all the fixtures are teared down and no longer usable, when this
# method is being called by pytest, hence they are called as functions.
integration_tests_configdict = integration_tests_config()

integration_tests_config = config.option.integration_tests_config
try:
doku_conn = dokuwiki.DokuWiki(
url=integration_tests_configdict["dokuwiki"]["url"],
user=integration_tests_configdict["dokuwiki"]["username"],
password=integration_tests_configdict["dokuwiki"]["password"])
url=integration_tests_config["dokuwiki"]["url"],
user=integration_tests_config["dokuwiki"]["username"],
password=integration_tests_config["dokuwiki"]["password"])
except gaierror, dokuwiki.DokuWikiError:
print "Dokuwiki connection not established, report upload failed!"
else:
Expand All @@ -70,15 +77,8 @@ def pytest_unconfigure(config):


@pytest.fixture(scope="session")
def integration_tests_config():
integration_tests_configpath = pytest.config.getvalue("integration-tests")
if integration_tests_configpath is None:
pytest.skip('--integration-tests was not specified')
else:
integration_tests_configpath = os.path.expandvars(
os.path.expanduser(integration_tests_configpath)
)
return yaml.load(open(integration_tests_configpath))
def integration_tests_config(request):
return request.config.option.integration_tests_config


@pytest.fixture(scope="session")
Expand Down
2 changes: 2 additions & 0 deletions tardis/tests/tests_slow/test_w7.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from tardis.io.config_reader import Configuration


@pytest.mark.skipif(not pytest.config.getvalue("integration-tests"),
reason="integration tests are not included in this run")
class TestW7(object):
"""
Slow integration test for Stratified W7 setup.
Expand Down

0 comments on commit d6b97f3

Please sign in to comment.