14
14
pytest_plugins = ("pytester" ,)
15
15
16
16
17
- def handle_tr_writer_deprecation ( ):
18
- # Remove this function when they've fixed
17
+ def remove_deprecation_from_recwarn ( recwarn ):
18
+ # TODO: Temporary hack until they fix
19
19
# https://github.com/pytest-dev/pytest/issues/6936
20
- import warnings
21
- from _pytest .warnings import _setoption
22
-
23
- arg = "ignore:TerminalReporter.writer:pytest.PytestDeprecationWarning"
24
- _setoption (warnings , arg )
20
+ return [
21
+ item for item in recwarn if "TerminalReporter.writer" not in repr (item .message )
22
+ ]
23
+ # for index, item in enumerate(recwarn):
24
+ # if "TerminalReporter.writer" in repr(item.message):
25
+ # del recwarn.list[index]
25
26
26
27
27
28
def run (testdir , path = "report.html" , * args ):
28
- # TODO: Temporary hack until they fix
29
- # https://github.com/pytest-dev/pytest/issues/6936
30
- handle_tr_writer_deprecation () # TODO: Temporary hack
31
29
path = testdir .tmpdir .join (path )
32
30
result = testdir .runpytest ("--html" , path , * args )
33
31
return result , read_html (path )
@@ -232,9 +230,6 @@ def test_report_title(self, testdir, path):
232
230
assert report_title in html
233
231
234
232
def test_report_title_addopts_env_var (self , testdir , monkeypatch ):
235
- # TODO: Temporary hack until they fix
236
- # https://github.com/pytest-dev/pytest/issues/6936
237
- handle_tr_writer_deprecation ()
238
233
report_location = "REPORT_LOCATION"
239
234
report_name = "MuhReport"
240
235
monkeypatch .setenv (report_location , report_name )
@@ -881,7 +876,8 @@ def test_css(self, testdir, recwarn, colors):
881
876
cssargs .extend (["--css" , path ])
882
877
result , html = run (testdir , "report.html" , "--self-contained-html" , * cssargs )
883
878
assert result .ret == 0
884
- assert len (recwarn ) == 0
879
+ warnings = remove_deprecation_from_recwarn (recwarn )
880
+ assert len (warnings ) == 0
885
881
for k , v in css .items ():
886
882
assert str (v ["path" ]) in html
887
883
assert v ["style" ] in html
@@ -894,9 +890,6 @@ def test_css_invalid(self, testdir, recwarn):
894
890
assert "No such file or directory: 'style.css'" in result .stderr .str ()
895
891
896
892
def test_css_invalid_no_html (self , testdir ):
897
- # TODO: Temporary hack until they fix
898
- # https://github.com/pytest-dev/pytest/issues/6936
899
- handle_tr_writer_deprecation ()
900
893
testdir .makepyfile ("def test_pass(): pass" )
901
894
result = testdir .runpytest ("--css" , "style.css" )
902
895
assert result .ret == 0
0 commit comments