Skip to content

Commit

Permalink
Mark flaky test on with xfail
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Nov 20, 2023
1 parent 3bd67c0 commit 6d952d7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion setuptools/tests/test_logging.py
@@ -1,10 +1,14 @@
import inspect
import logging
import os
import sys

import pytest


IS_PYPY = '__pypy__' in sys.builtin_module_names


setup_py = """\
from setuptools import setup
Expand Down Expand Up @@ -38,16 +42,29 @@ def test_verbosity_level(tmp_path, monkeypatch, flag, expected_level):
assert log_level_name == expected_level


def _flaky_on_pypy(func):
try:
func()
except AssertionError:
if IS_PYPY:
msg = "Flaky monkeypatch on PyPy"
pytest.xfail(f"{msg}. Original discussion in #3707, #3709.")
raise


@_flaky_on_pypy
def test_patching_does_not_cause_problems():
# Ensure `dist.log` is only patched if necessary

import _distutils_hack
import setuptools.logging
from distutils import dist

setuptools.logging.configure()

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

0 comments on commit 6d952d7

Please sign in to comment.