parent
a5b5090c72
commit
629d8e9fd6
|
@ -3,7 +3,10 @@
|
|||
|
||||
*
|
||||
|
||||
*
|
||||
* An error message is now displayed if ``--confcutdir`` is not a valid directory, avoiding
|
||||
subtle bugs (`#2078`_).
|
||||
Thanks `@nicoddemus`_ for the PR.
|
||||
|
||||
|
||||
* Cope gracefully with a .pyc file with no matching .py file (`#2038`_). Thanks
|
||||
`@nedbat`_.
|
||||
|
@ -15,6 +18,7 @@
|
|||
.. _@nedbat: https://github.com/nedbat
|
||||
|
||||
.. _#2038: https://github.com/pytest-dev/pytest/issues/2038
|
||||
.. _#2078: https://github.com/pytest-dev/pytest/issues/2078
|
||||
|
||||
|
||||
3.0.4
|
||||
|
|
|
@ -996,6 +996,7 @@ class Config(object):
|
|||
"(are you using python -O?)\n")
|
||||
|
||||
def _preparse(self, args, addopts=True):
|
||||
import pytest
|
||||
self._initini(args)
|
||||
if addopts:
|
||||
args[:] = shlex.split(os.environ.get('PYTEST_ADDOPTS', '')) + args
|
||||
|
@ -1007,7 +1008,10 @@ class Config(object):
|
|||
self.pluginmanager.load_setuptools_entrypoints(entrypoint_name)
|
||||
self.pluginmanager.consider_env()
|
||||
self.known_args_namespace = ns = self._parser.parse_known_args(args, namespace=self.option.copy())
|
||||
if self.known_args_namespace.confcutdir is None and self.inifile:
|
||||
confcutdir = self.known_args_namespace.confcutdir
|
||||
if confcutdir and not os.path.isdir(confcutdir):
|
||||
raise pytest.UsageError('--confcutdir must be a directory, given: {0}'.format(confcutdir))
|
||||
if confcutdir is None and self.inifile:
|
||||
confcutdir = py.path.local(self.inifile).dirname
|
||||
self.known_args_namespace.confcutdir = confcutdir
|
||||
try:
|
||||
|
|
|
@ -294,6 +294,15 @@ class TestConfigAPI:
|
|||
assert len(l) == 2
|
||||
assert l == ["456", "123"]
|
||||
|
||||
def test_confcutdir_check_isdir(self, testdir):
|
||||
"""Give an error if --confcutdir is not a valid directory (#2078)"""
|
||||
with pytest.raises(pytest.UsageError):
|
||||
testdir.parseconfig('--confcutdir', testdir.tmpdir.join('file').ensure(file=1))
|
||||
with pytest.raises(pytest.UsageError):
|
||||
testdir.parseconfig('--confcutdir', testdir.tmpdir.join('inexistant'))
|
||||
config = testdir.parseconfig('--confcutdir', testdir.tmpdir.join('dir').ensure(dir=1))
|
||||
assert config.getoption('confcutdir') == str(testdir.tmpdir.join('dir'))
|
||||
|
||||
|
||||
class TestConfigFromdictargs:
|
||||
def test_basic_behavior(self):
|
||||
|
|
Loading…
Reference in New Issue