Fix testing with WSL (#516)
This commit is contained in:
parent
1d69ce370c
commit
1e5612d707
2 changed files with 12 additions and 4 deletions
|
@ -93,7 +93,13 @@ def tst_distro_family(runner):
|
|||
@pytest.fixture(scope="session")
|
||||
def tst_sys():
|
||||
"""Test session's uname value"""
|
||||
return platform.system()
|
||||
system = platform.system()
|
||||
if system == "Linux":
|
||||
# Additional check for WSL
|
||||
with open("/proc/version", "r", encoding="utf-8") as f:
|
||||
if "icrosoft" in f.read():
|
||||
return "WSL"
|
||||
return system
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
|
|
|
@ -24,8 +24,7 @@ def test_set_operating_system(runner, paths, tst_sys, proc_value, expected_os):
|
|||
# Normally /proc/version (set in PROC_VERSION) is inspected to identify
|
||||
# WSL. During testing, we will override that value.
|
||||
proc_version = paths.root.join("proc_version")
|
||||
if proc_value != "missing":
|
||||
proc_version.write(proc_value)
|
||||
proc_version.write(proc_value)
|
||||
script = f"""
|
||||
YADM_TEST=1 source {paths.pgm}
|
||||
PROC_VERSION={proc_version}
|
||||
|
@ -36,5 +35,8 @@ def test_set_operating_system(runner, paths, tst_sys, proc_value, expected_os):
|
|||
assert run.success
|
||||
assert run.err == ""
|
||||
if expected_os == "uname":
|
||||
expected_os = tst_sys
|
||||
if tst_sys != "WSL":
|
||||
expected_os = tst_sys
|
||||
else:
|
||||
expected_os = "Linux"
|
||||
assert run.out.rstrip() == expected_os
|
||||
|
|
Loading…
Reference in a new issue