Skip to content

Commit 5af8f75

Browse files
committed
test: Mark some xfails based on if in docker instead of in CI
Makes them apply better in local docker runs.
1 parent 3780c80 commit 5af8f75

File tree

6 files changed

+22
-18
lines changed

6 files changed

+22
-18
lines changed

test/t/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ def completion(request, bash: pexpect.spawn) -> CompletionResult:
344344
return assert_complete(bash, marker.args[0], **marker.kwargs)
345345

346346

347+
def in_docker() -> bool:
348+
return os.path.exists("/.dockerenv")
349+
350+
347351
class TestUnitBase:
348352

349353
def _test_unit(self, func, bash,

test/t/test_arp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import os
2-
31
import pytest
42

3+
from conftest import in_docker
4+
55

66
class TestArp:
77

8-
@pytest.mark.xfail(bool(os.environ.get("CI")),
9-
reason="Probably fails in CI")
8+
@pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
9+
@pytest.mark.complete("arp ")
1010
def test_1(self, completion):
1111
assert completion.list
1212

test/t/test_ifdown.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import os
2-
31
import pytest
42

3+
from conftest import in_docker
4+
55

66
class TestIfdown:
77

8-
@pytest.mark.xfail(bool(os.environ.get("CI")),
9-
reason="Probably fails in CI")
8+
@pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
109
@pytest.mark.complete("ifdown ")
1110
def test_1(self, completion):
1211
assert completion.list

test/t/test_ifup.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import os
2-
31
import pytest
42

3+
from conftest import in_docker
4+
55

66
class TestIfup:
77

8-
@pytest.mark.xfail(bool(os.environ.get("CI")),
9-
reason="Probably fails in CI")
8+
@pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
109
@pytest.mark.complete("ifup ")
1110
def test_1(self, completion):
1211
assert completion.list

test/t/test_make.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import pytest
44

5+
from conftest import in_docker
6+
57

68
class TestMake:
79

@@ -34,10 +36,9 @@ def test_6(self, bash, completion):
3436
"all clean extra_makefile install sample".split()
3537
os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))
3638

37-
@pytest.mark.xfail(
38-
bool(os.environ.get("CI")) and os.environ.get("DIST") == "centos6",
39-
reason="Fails for some unknown reason on CentOS 6, even though "
40-
"the behavior appears to be correct")
39+
@pytest.mark.xfail(in_docker() and os.environ.get("DIST") == "centos6",
40+
reason="Fails for some unknown reason on CentOS 6, "
41+
"even though the behavior appears to be correct")
4142
@pytest.mark.complete("make .cache/.", cwd="make")
4243
def test_7(self, bash, completion):
4344
assert completion.list == ".1 .2".split()

test/t/test_man.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import pytest
44

5+
from conftest import in_docker
6+
57

68
@pytest.mark.bashcomp(ignore_env=r"^[+-]MANPATH=")
79
class TestMan:
@@ -22,8 +24,7 @@ def test_2(self, completion):
2224
def test_3(self, completion):
2325
assert completion.list == ["man/quux.8"]
2426

25-
@pytest.mark.xfail(bool(os.environ.get("CI")) and
26-
os.environ.get("DIST") == "centos6",
27+
@pytest.mark.xfail(in_docker() and os.environ.get("DIST") == "centos6",
2728
reason="TODO: Fails in CentOS for some reason, unknown "
2829
"how to trigger same behavior as tests show (is "
2930
"different and correct when tried manually, but here "

0 commit comments

Comments
 (0)