Attempt to fix flaky test on Python 2
This test sometimes fails on AppVeyor with:
```
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.0 = <listiterator object at 0x0549DC50>
leaked_types = sum(1 for _ in gc.garbage
> if 'PseudoFixtureDef' in str(_))
E UnicodeEncodeError: 'ascii' codec can't encode character u'\u263a' in position 23: ordinal not in range(128)
test_request_garbage.py:19: UnicodeEncodeError
====================== 1 passed, 1 error in 1.39 seconds ======================
```
Use our internal "safe_repr" function to handle Encode errors: who knows
what objects are in garbage after all.
This commit is contained in:
parent
27651f4032
commit
fa76a5c8fe
|
|
@ -523,6 +523,7 @@ class TestRequestBasic(object):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import sys
|
import sys
|
||||||
import pytest
|
import pytest
|
||||||
|
from _pytest.compat import safe_str
|
||||||
import gc
|
import gc
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
|
|
@ -539,7 +540,7 @@ class TestRequestBasic(object):
|
||||||
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
leaked_types = sum(1 for _ in gc.garbage
|
leaked_types = sum(1 for _ in gc.garbage
|
||||||
if 'PseudoFixtureDef' in str(_))
|
if 'PseudoFixtureDef' in safe_str(_))
|
||||||
|
|
||||||
gc.garbage[:] = []
|
gc.garbage[:] = []
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue