Skip to content

Commit b8992ad

Browse files
authored
Mark flaky test on PyPy with xfail (#4124)
2 parents 3bd67c0 + f53d7ad commit b8992ad

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

setuptools/tests/test_logging.py

+23-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import functools
12
import inspect
23
import logging
3-
import os
4+
import sys
45

56
import pytest
67

78

9+
IS_PYPY = '__pypy__' in sys.builtin_module_names
10+
11+
812
setup_py = """\
913
from setuptools import setup
1014
@@ -38,16 +42,33 @@ def test_verbosity_level(tmp_path, monkeypatch, flag, expected_level):
3842
assert log_level_name == expected_level
3943

4044

45+
def flaky_on_pypy(func):
46+
@functools.wraps(func)
47+
def _func():
48+
try:
49+
func()
50+
except AssertionError: # pragma: no cover
51+
if IS_PYPY:
52+
msg = "Flaky monkeypatch on PyPy (#4124)"
53+
pytest.xfail(f"{msg}. Original discussion in #3707, #3709.")
54+
raise
55+
56+
return _func
57+
58+
59+
@flaky_on_pypy
4160
def test_patching_does_not_cause_problems():
4261
# Ensure `dist.log` is only patched if necessary
4362

63+
import _distutils_hack
4464
import setuptools.logging
4565
from distutils import dist
4666

4767
setuptools.logging.configure()
4868

49-
if os.getenv("SETUPTOOLS_USE_DISTUTILS", "local").lower() == "local":
69+
if _distutils_hack.enabled():
5070
# Modern logging infra, no problematic patching.
71+
assert dist.__file__ is None or "setuptools" in dist.__file__
5172
assert isinstance(dist.log, logging.Logger)
5273
else:
5374
assert inspect.ismodule(dist.log)

0 commit comments

Comments
 (0)