Skip to content

Commit db1233d

Browse files
a
1 parent 449bdd7 commit db1233d

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

ddtrace/contrib/internal/pytest/_plugin_v2.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,15 @@ def _handle_test_management(item, test_id):
119119
skipping mode.
120120
"""
121121
is_quarantined = InternalTest.is_quarantined_test(test_id)
122-
if is_quarantined:
123-
# We add this information to user_properties to have it available in pytest_runtest_makereport().
124-
item.user_properties += [(USER_PROPERTY_QUARANTINED, True)]
125-
126122
is_disabled = InternalTest.is_disabled_test(test_id)
123+
127124
if is_disabled:
125+
# A test that is both disabled and quarantined should be skipped just like a regular disabled test.
126+
# It should still have both disabled and quarantined event tags, though.
128127
item.add_marker(pytest.mark.skip(reason=DISABLED_BY_TEST_MANAGEMENT_REASON))
128+
elif is_quarantined:
129+
# We add this information to user_properties to have it available in pytest_runtest_makereport().
130+
item.user_properties += [(USER_PROPERTY_QUARANTINED, True)]
129131

130132

131133
def _start_collecting_coverage() -> ModuleCodeCollector.CollectInContext:

tests/contrib/pytest/test_pytest_disabling.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@
2323
_make_fqdn_internal_test_id("", "test_disabling.py", "test_disabled"): TestProperties(
2424
disabled=True
2525
),
26-
_make_fqdn_internal_test_id("", "test_disabling.py", "test_enabled"): TestProperties(
27-
disabled=False
26+
_make_fqdn_internal_test_id("", "test_disabling.py", "test_quarantined"): TestProperties(
27+
quarantined=True
28+
),
29+
_make_fqdn_internal_test_id("", "test_disabling.py", "test_disabled_and_quarantined"): TestProperties(
30+
quarantined=True,
31+
disabled=True,
2832
),
2933
}
3034

@@ -34,6 +38,12 @@
3438
def test_disabled():
3539
assert False
3640
41+
def test_quarantined():
42+
assert False
43+
44+
def test_disabled_and_quarantined():
45+
assert False
46+
3747
def test_pass():
3848
assert True
3949
@@ -76,7 +86,8 @@ def set_up_test_management(self):
7686
def test_disabling(self):
7787
self.testdir.makepyfile(test_disabling=_TESTS)
7888
rec = self.inline_run("--ddtrace", "-v")
79-
assert_stats(rec, passed=1, failed=1, skipped=1)
89+
assert rec.ret == 1
90+
assert_stats(rec, passed=1, failed=1, skipped=2, quarantined=1)
8091

8192

8293
# def test_fail_quarantined_no_ddtrace_does_not_quarantine(self):

0 commit comments

Comments
 (0)