Skip to content

Commit 6d661ac

Browse files
Merge pull request #1523 from MengJueM/master
2 parents a986b8f + f51c34e commit 6d661ac

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@ Russel Winder
8787
Ben Webb
8888
Alexei Kozlenok
8989
Cal Leeming
90+
Feng Ma

CHANGELOG.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
*
77

8-
*
8+
* Fix win32 path issue when puttinging custom config file with absolute path
9+
in ``pytest.main("-c your_absolute_path")``.
910

1011
* Fix maximum recursion depth detection when raised error class is not aware
1112
of unicode/encoded bytes.

_pytest/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _prepareconfig(args=None, plugins=None):
104104
elif not isinstance(args, (tuple, list)):
105105
if not isinstance(args, str):
106106
raise ValueError("not a string or argument list: %r" % (args,))
107-
args = shlex.split(args)
107+
args = shlex.split(args, posix=sys.platform == "win32")
108108
config = get_config()
109109
pluginmanager = config.pluginmanager
110110
try:

testing/test_config.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def test_confcutdir(self, testdir):
7979
""")
8080
result = testdir.inline_run("--confcutdir=.")
8181
assert result.ret == 0
82-
82+
8383
class TestConfigCmdlineParsing:
8484
def test_parsing_again_fails(self, testdir):
8585
config = testdir.parseconfig()
@@ -101,6 +101,16 @@ def pytest_addoption(parser):
101101
config = testdir.parseconfig("-c", "custom.cfg")
102102
assert config.getini("custom") == "1"
103103

104+
def test_absolute_win32_path(self, testdir):
105+
temp_cfg_file = testdir.makefile(".cfg", custom="""
106+
[pytest]
107+
addopts = --version
108+
""")
109+
from os.path import normpath
110+
temp_cfg_file = normpath(str(temp_cfg_file))
111+
ret = pytest.main("-c " + temp_cfg_file)
112+
assert ret == _pytest.main.EXIT_OK
113+
104114
class TestConfigAPI:
105115
def test_config_trace(self, testdir):
106116
config = testdir.parseconfig()

0 commit comments

Comments
 (0)