diff options
author | feuillemorte <fmorte@ya.ru> | 2018-02-01 00:03:24 +0300 |
---|---|---|
committer | feuillemorte <fmorte@ya.ru> | 2018-02-01 00:03:24 +0300 |
commit | 741b571f3b6cd1bcfec6db7ba90f112cd5bbc8d1 (patch) | |
tree | 3311e6868303d5bb9511275789eea1012c0bc673 /testing/test_session.py | |
parent | ace772c7433b7bf38c2e2908a2535cae6ea4a175 (diff) | |
download | pytest-741b571f3b6cd1bcfec6db7ba90f112cd5bbc8d1.tar.gz |
#1642 fix tests and config.py
Diffstat (limited to 'testing/test_session.py')
-rw-r--r-- | testing/test_session.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/testing/test_session.py b/testing/test_session.py index 798e1d9cb..5f85c6309 100644 --- a/testing/test_session.py +++ b/testing/test_session.py @@ -1,4 +1,7 @@ from __future__ import absolute_import, division, print_function + +import os + import pytest from _pytest.main import EXIT_NOTESTSCOLLECTED @@ -255,20 +258,24 @@ def test_sessionfinish_with_start(testdir): assert res.ret == EXIT_NOTESTSCOLLECTED -def test_rootdir_option_arg(testdir): +@pytest.mark.parametrize("path", ["root", "{relative}/root", "{environment}/root"]) +def test_rootdir_option_arg(testdir, path): + if 'relative' in path: + path = path.format(relative=os.getcwd()) + if 'environment' in path: + os.environ['PY_ROOTDIR_PATH'] = os.getcwd() + path = path.format(environment='$PY_ROOTDIR_PATH') + rootdir = testdir.mkdir("root") rootdir.mkdir("tests") testdir.makepyfile(""" import os def test_one(): - assert os.path.isdir('.cache') + assert 1 """) - result = testdir.runpytest() - result.stdout.fnmatch_lines(["*AssertionError*"]) - - result = testdir.runpytest("--rootdir=root") - result.stdout.fnmatch_lines(["*1 passed*"]) + result = testdir.runpytest("--rootdir={}".format(os.path.expandvars(path))) + result.stdout.fnmatch_lines(['*rootdir: {}/root, inifile:*'.format(os.getcwd()), "*1 passed*"]) def test_rootdir_wrong_option_arg(testdir): |