summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2022-10-04 17:57:08 -0400
committerJason R. Coombs <jaraco@jaraco.com>2022-10-04 17:57:08 -0400
commite615a4d0a0002d23127db19c4febc54d6080378e (patch)
tree7347bdb7c10cd757742ed736fde8573234bcead2
parenta1e48e7feb64e54eb22d490e31ec16348d9b7912 (diff)
downloadpython-setuptools-git-e615a4d0a0002d23127db19c4febc54d6080378e.tar.gz
Consolidate fixture for capturing logs. Removes LoggingSilencer.
-rw-r--r--conftest.py15
-rw-r--r--distutils/tests/support.py17
-rw-r--r--distutils/tests/test_archive_util.py2
-rw-r--r--distutils/tests/test_bdist_dumb.py1
-rw-r--r--distutils/tests/test_bdist_rpm.py1
-rw-r--r--distutils/tests/test_build.py2
-rw-r--r--distutils/tests/test_build_clib.py2
-rw-r--r--distutils/tests/test_build_ext.py3
-rw-r--r--distutils/tests/test_build_py.py6
-rw-r--r--distutils/tests/test_build_scripts.py2
-rw-r--r--distutils/tests/test_check.py2
-rw-r--r--distutils/tests/test_clean.py2
-rw-r--r--distutils/tests/test_config.py5
-rw-r--r--distutils/tests/test_config_cmd.py2
-rw-r--r--distutils/tests/test_dist.py5
-rw-r--r--distutils/tests/test_filelist.py49
-rw-r--r--distutils/tests/test_install.py16
-rw-r--r--distutils/tests/test_install_data.py1
-rw-r--r--distutils/tests/test_install_headers.py1
-rw-r--r--distutils/tests/test_install_lib.py5
-rw-r--r--distutils/tests/test_install_scripts.py2
-rw-r--r--distutils/tests/test_register.py9
-rw-r--r--distutils/tests/test_sdist.py24
-rw-r--r--distutils/tests/test_spawn.py2
-rw-r--r--distutils/tests/test_upload.py14
25 files changed, 71 insertions, 119 deletions
diff --git a/conftest.py b/conftest.py
index 731bf0af..7427da7a 100644
--- a/conftest.py
+++ b/conftest.py
@@ -36,19 +36,6 @@ def needs_zlib():
pytest.importorskip('zlib')
-@pytest.fixture
-def distutils_logging_silencer(request, monkeypatch):
- from distutils import log
-
- self = request.instance
- # catching warnings
- # when log will be replaced by logging
- # we won't need such monkey-patch anymore
- monkeypatch.setattr(log.Log, '_log', self._log)
- self.logs = []
- monkeypatch.setattr(log._global_log, 'threshold', log.FATAL)
-
-
# from jaraco.collections
class Everything:
def __contains__(self, other):
@@ -58,7 +45,7 @@ class Everything:
class SavedLogs(list):
def render(self, *levels):
return [
- msg % args for level, msg, args in self if level in levels or Everything()
+ msg % args for level, msg, args in self if level in (levels or Everything())
]
diff --git a/distutils/tests/support.py b/distutils/tests/support.py
index 5203ed19..86431539 100644
--- a/distutils/tests/support.py
+++ b/distutils/tests/support.py
@@ -8,26 +8,9 @@ import itertools
import pytest
-from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL
from distutils.core import Distribution
-@pytest.mark.usefixtures('distutils_logging_silencer')
-class LoggingSilencer:
- def _log(self, level, msg, args):
- if level not in (DEBUG, INFO, WARN, ERROR, FATAL):
- raise ValueError('%s wrong log level' % str(level))
- if not isinstance(msg, str):
- raise TypeError("msg should be str, not '%.200s'" % (type(msg).__name__))
- self.logs.append((level, msg, args))
-
- def get_logs(self, *levels):
- return [msg % args for level, msg, args in self.logs if level in levels]
-
- def clear_logs(self):
- self.logs = []
-
-
@pytest.mark.usefixtures('distutils_managed_tempdir')
class TempdirManager:
"""
diff --git a/distutils/tests/test_archive_util.py b/distutils/tests/test_archive_util.py
index d0f5b734..7778c3ad 100644
--- a/distutils/tests/test_archive_util.py
+++ b/distutils/tests/test_archive_util.py
@@ -48,7 +48,7 @@ def same_drive(*paths):
return all_equal(pathlib.Path(path).drive for path in paths)
-class ArchiveUtilTestCase(support.TempdirManager, support.LoggingSilencer):
+class ArchiveUtilTestCase(support.TempdirManager):
@pytest.mark.usefixtures('needs_zlib')
def test_make_tarball(self, name='archive'):
# creating something to tar
diff --git a/distutils/tests/test_bdist_dumb.py b/distutils/tests/test_bdist_dumb.py
index 8624a429..b9bec051 100644
--- a/distutils/tests/test_bdist_dumb.py
+++ b/distutils/tests/test_bdist_dumb.py
@@ -26,7 +26,6 @@ setup(name='foo', version='0.1', py_modules=['foo'],
@pytest.mark.usefixtures('save_cwd')
class TestBuildDumb(
support.TempdirManager,
- support.LoggingSilencer,
):
@pytest.mark.usefixtures('needs_zlib')
def test_simple_built(self):
diff --git a/distutils/tests/test_bdist_rpm.py b/distutils/tests/test_bdist_rpm.py
index 2d14bafc..4a702fb9 100644
--- a/distutils/tests/test_bdist_rpm.py
+++ b/distutils/tests/test_bdist_rpm.py
@@ -42,7 +42,6 @@ mac_woes = pytest.mark.skipif(
@pytest.mark.usefixtures('save_cwd')
class TestBuildRpm(
support.TempdirManager,
- support.LoggingSilencer,
):
@mac_woes
@requires_zlib()
diff --git a/distutils/tests/test_build.py b/distutils/tests/test_build.py
index 80367607..66d8af50 100644
--- a/distutils/tests/test_build.py
+++ b/distutils/tests/test_build.py
@@ -7,7 +7,7 @@ from distutils.tests import support
from sysconfig import get_platform
-class TestBuild(support.TempdirManager, support.LoggingSilencer):
+class TestBuild(support.TempdirManager):
def test_finalize_options(self):
pkg_dir, dist = self.create_dist()
cmd = build(dist)
diff --git a/distutils/tests/test_build_clib.py b/distutils/tests/test_build_clib.py
index c931c06e..709d0b7d 100644
--- a/distutils/tests/test_build_clib.py
+++ b/distutils/tests/test_build_clib.py
@@ -10,7 +10,7 @@ from distutils.errors import DistutilsSetupError
from distutils.tests import support
-class TestBuildCLib(support.TempdirManager, support.LoggingSilencer):
+class TestBuildCLib(support.TempdirManager):
def test_check_library_dist(self):
pkg_dir, dist = self.create_dist()
cmd = build_clib(dist)
diff --git a/distutils/tests/test_build_ext.py b/distutils/tests/test_build_ext.py
index cf6e9898..f5058487 100644
--- a/distutils/tests/test_build_ext.py
+++ b/distutils/tests/test_build_ext.py
@@ -18,7 +18,6 @@ from distutils.command.build_ext import build_ext
from distutils import sysconfig
from distutils.tests.support import (
TempdirManager,
- LoggingSilencer,
copy_xxmodule_c,
fixup_build_ext,
)
@@ -85,7 +84,7 @@ def extension_redirect(mod, path):
@pytest.mark.usefixtures('user_site_dir')
-class TestBuildExt(TempdirManager, LoggingSilencer):
+class TestBuildExt(TempdirManager):
def build_ext(self, *args, **kwargs):
return build_ext(*args, **kwargs)
diff --git a/distutils/tests/test_build_py.py b/distutils/tests/test_build_py.py
index 63543dca..57538183 100644
--- a/distutils/tests/test_build_py.py
+++ b/distutils/tests/test_build_py.py
@@ -14,7 +14,7 @@ from distutils.tests import support
@support.combine_markers
-class TestBuildPy(support.TempdirManager, support.LoggingSilencer):
+class TestBuildPy(support.TempdirManager):
def test_package_data(self):
sources = self.mkdtemp()
f = open(os.path.join(sources, "__init__.py"), "w")
@@ -151,7 +151,7 @@ class TestBuildPy(support.TempdirManager, support.LoggingSilencer):
except DistutilsFileError:
self.fail("failed package_data when data dir includes a dir")
- def test_dont_write_bytecode(self):
+ def test_dont_write_bytecode(self, logs):
# makes sure byte_compile is not used
dist = self.create_dist()[1]
cmd = build_py(dist)
@@ -165,7 +165,7 @@ class TestBuildPy(support.TempdirManager, support.LoggingSilencer):
finally:
sys.dont_write_bytecode = old_dont_write_bytecode
- assert 'byte-compiling is disabled' in self.logs[0][1] % self.logs[0][2]
+ assert 'byte-compiling is disabled' in logs.render()[0]
@mock.patch("distutils.command.build_py.log.warn")
def test_namespace_package_does_not_warn(self, log_warn):
diff --git a/distutils/tests/test_build_scripts.py b/distutils/tests/test_build_scripts.py
index 00d7fc59..1a5753c7 100644
--- a/distutils/tests/test_build_scripts.py
+++ b/distutils/tests/test_build_scripts.py
@@ -9,7 +9,7 @@ from distutils import sysconfig
from distutils.tests import support
-class TestBuildScripts(support.TempdirManager, support.LoggingSilencer):
+class TestBuildScripts(support.TempdirManager):
def test_default_settings(self):
cmd = self.get_build_scripts_cmd("/foo/bar", [])
assert not cmd.force
diff --git a/distutils/tests/test_check.py b/distutils/tests/test_check.py
index 3e5f6034..54654067 100644
--- a/distutils/tests/test_check.py
+++ b/distutils/tests/test_check.py
@@ -18,7 +18,7 @@ HERE = os.path.dirname(__file__)
@support.combine_markers
-class TestCheck(support.LoggingSilencer, support.TempdirManager):
+class TestCheck(support.TempdirManager):
def _run(self, metadata=None, cwd=None, **options):
if metadata is None:
metadata = {}
diff --git a/distutils/tests/test_clean.py b/distutils/tests/test_clean.py
index 4166bb7e..157b60a1 100644
--- a/distutils/tests/test_clean.py
+++ b/distutils/tests/test_clean.py
@@ -5,7 +5,7 @@ from distutils.command.clean import clean
from distutils.tests import support
-class TestClean(support.TempdirManager, support.LoggingSilencer):
+class TestClean(support.TempdirManager):
def test_simple_run(self):
pkg_dir, dist = self.create_dist()
cmd = clean(dist)
diff --git a/distutils/tests/test_config.py b/distutils/tests/test_config.py
index 43ba6766..cdf73bb9 100644
--- a/distutils/tests/test_config.py
+++ b/distutils/tests/test_config.py
@@ -48,10 +48,7 @@ password:xxx
@support.combine_markers
@pytest.mark.usefixtures('threshold_warn')
@pytest.mark.usefixtures('pypirc')
-class BasePyPIRCCommandTestCase(
- support.TempdirManager,
- support.LoggingSilencer,
-):
+class BasePyPIRCCommandTestCase(support.TempdirManager):
pass
diff --git a/distutils/tests/test_config_cmd.py b/distutils/tests/test_config_cmd.py
index 65c60f64..6d13c24f 100644
--- a/distutils/tests/test_config_cmd.py
+++ b/distutils/tests/test_config_cmd.py
@@ -18,7 +18,7 @@ def info_log(request, monkeypatch):
@support.combine_markers
-class TestConfig(support.LoggingSilencer, support.TempdirManager):
+class TestConfig(support.TempdirManager):
def _info(self, msg, *args):
for line in msg.splitlines():
self._logs.append(line)
diff --git a/distutils/tests/test_dist.py b/distutils/tests/test_dist.py
index 52e0b3ce..385007f2 100644
--- a/distutils/tests/test_dist.py
+++ b/distutils/tests/test_dist.py
@@ -52,10 +52,7 @@ def clear_argv():
@support.combine_markers
@pytest.mark.usefixtures('save_env')
@pytest.mark.usefixtures('save_argv')
-class TestDistributionBehavior(
- support.LoggingSilencer,
- support.TempdirManager,
-):
+class TestDistributionBehavior(support.TempdirManager):
def create_distribution(self, configfiles=()):
d = TestDistribution()
d._config_files = configfiles
diff --git a/distutils/tests/test_filelist.py b/distutils/tests/test_filelist.py
index 7ff9d3e8..74a2a41d 100644
--- a/distutils/tests/test_filelist.py
+++ b/distutils/tests/test_filelist.py
@@ -12,7 +12,6 @@ from test.support import captured_stdout
import pytest
import jaraco.path
-from distutils.tests import support
from . import py38compat as os_helper
@@ -37,14 +36,14 @@ def make_local_path(s):
return s.replace('/', os.sep)
-class TestFileList(support.LoggingSilencer):
- def assertNoWarnings(self):
- assert self.get_logs(WARN) == []
- self.clear_logs()
+class TestFileList:
+ def assertNoWarnings(self, logs):
+ assert logs.render(WARN) == []
+ logs.clear()
- def assertWarnings(self):
- assert len(self.get_logs(WARN)) > 0
- self.clear_logs()
+ def assertWarnings(self, logs):
+ assert logs.render(WARN)
+ logs.clear()
def test_glob_to_re(self):
sep = os.sep
@@ -188,7 +187,7 @@ class TestFileList(support.LoggingSilencer):
file_list.include_pattern('*')
assert file_list.allfiles == ['a.py', 'b.txt']
- def test_process_template(self):
+ def test_process_template(self, logs):
mlp = make_local_path
# invalid lines
file_list = FileList()
@@ -212,11 +211,11 @@ class TestFileList(support.LoggingSilencer):
file_list.process_template_line('include *.py')
assert file_list.files == ['a.py']
- self.assertNoWarnings()
+ self.assertNoWarnings(logs)
file_list.process_template_line('include *.rb')
assert file_list.files == ['a.py']
- self.assertWarnings()
+ self.assertWarnings(logs)
# exclude
file_list = FileList()
@@ -224,11 +223,11 @@ class TestFileList(support.LoggingSilencer):
file_list.process_template_line('exclude *.py')
assert file_list.files == ['b.txt', mlp('d/c.py')]
- self.assertNoWarnings()
+ self.assertNoWarnings(logs)
file_list.process_template_line('exclude *.rb')
assert file_list.files == ['b.txt', mlp('d/c.py')]
- self.assertWarnings()
+ self.assertWarnings(logs)
# global-include
file_list = FileList()
@@ -236,11 +235,11 @@ class TestFileList(support.LoggingSilencer):
file_list.process_template_line('global-include *.py')
assert file_list.files == ['a.py', mlp('d/c.py')]
- self.assertNoWarnings()
+ self.assertNoWarnings(logs)
file_list.process_template_line('global-include *.rb')
assert file_list.files == ['a.py', mlp('d/c.py')]
- self.assertWarnings()
+ self.assertWarnings(logs)
# global-exclude
file_list = FileList()
@@ -248,11 +247,11 @@ class TestFileList(support.LoggingSilencer):
file_list.process_template_line('global-exclude *.py')
assert file_list.files == ['b.txt']
- self.assertNoWarnings()
+ self.assertNoWarnings(logs)
file_list.process_template_line('global-exclude *.rb')
assert file_list.files == ['b.txt']
- self.assertWarnings()
+ self.assertWarnings(logs)
# recursive-include
file_list = FileList()
@@ -260,11 +259,11 @@ class TestFileList(support.LoggingSilencer):
file_list.process_template_line('recursive-include d *.py')
assert file_list.files == [mlp('d/b.py'), mlp('d/d/e.py')]
- self.assertNoWarnings()
+ self.assertNoWarnings(logs)
file_list.process_template_line('recursive-include e *.py')
assert file_list.files == [mlp('d/b.py'), mlp('d/d/e.py')]
- self.assertWarnings()
+ self.assertWarnings(logs)
# recursive-exclude
file_list = FileList()
@@ -272,11 +271,11 @@ class TestFileList(support.LoggingSilencer):
file_list.process_template_line('recursive-exclude d *.py')
assert file_list.files == ['a.py', mlp('d/c.txt')]
- self.assertNoWarnings()
+ self.assertNoWarnings(logs)
file_list.process_template_line('recursive-exclude e *.py')
assert file_list.files == ['a.py', mlp('d/c.txt')]
- self.assertWarnings()
+ self.assertWarnings(logs)
# graft
file_list = FileList()
@@ -284,11 +283,11 @@ class TestFileList(support.LoggingSilencer):
file_list.process_template_line('graft d')
assert file_list.files == [mlp('d/b.py'), mlp('d/d/e.py')]
- self.assertNoWarnings()
+ self.assertNoWarnings(logs)
file_list.process_template_line('graft e')
assert file_list.files == [mlp('d/b.py'), mlp('d/d/e.py')]
- self.assertWarnings()
+ self.assertWarnings(logs)
# prune
file_list = FileList()
@@ -296,11 +295,11 @@ class TestFileList(support.LoggingSilencer):
file_list.process_template_line('prune d')
assert file_list.files == ['a.py', mlp('f/f.py')]
- self.assertNoWarnings()
+ self.assertNoWarnings(logs)
file_list.process_template_line('prune e')
assert file_list.files == ['a.py', mlp('f/f.py')]
- self.assertWarnings()
+ self.assertWarnings(logs)
class TestFindAll:
diff --git a/distutils/tests/test_install.py b/distutils/tests/test_install.py
index 32a18b2f..f597ad3e 100644
--- a/distutils/tests/test_install.py
+++ b/distutils/tests/test_install.py
@@ -17,6 +17,7 @@ from distutils.command.install import INSTALL_SCHEMES
from distutils.core import Distribution
from distutils.errors import DistutilsOptionError
from distutils.extension import Extension
+from distutils.log import DEBUG
from distutils.tests import support
from test import support as test_support
@@ -30,7 +31,6 @@ def _make_ext_name(modname):
@pytest.mark.usefixtures('save_env')
class TestInstall(
support.TempdirManager,
- support.LoggingSilencer,
):
@pytest.mark.xfail(
'platform.system() == "Windows" and sys.version_info > (3, 11)',
@@ -246,13 +246,9 @@ class TestInstall(
]
assert found == expected
- def test_debug_mode(self):
+ def test_debug_mode(self, logs, monkeypatch):
# this covers the code called when DEBUG is set
- old_logs_len = len(self.logs)
- install_module.DEBUG = True
- try:
- with captured_stdout():
- self.test_record()
- finally:
- install_module.DEBUG = False
- assert len(self.logs) > old_logs_len
+ monkeypatch.setattr(install_module, 'DEBUG', True)
+ with captured_stdout():
+ self.test_record()
+ assert logs.render(DEBUG)
diff --git a/distutils/tests/test_install_data.py b/distutils/tests/test_install_data.py
index f77c790f..9badbc26 100644
--- a/distutils/tests/test_install_data.py
+++ b/distutils/tests/test_install_data.py
@@ -10,7 +10,6 @@ from distutils.tests import support
@pytest.mark.usefixtures('save_env')
class TestInstallData(
support.TempdirManager,
- support.LoggingSilencer,
):
def test_simple_run(self):
pkg_dir, dist = self.create_dist()
diff --git a/distutils/tests/test_install_headers.py b/distutils/tests/test_install_headers.py
index 7594f5af..1e8ccf79 100644
--- a/distutils/tests/test_install_headers.py
+++ b/distutils/tests/test_install_headers.py
@@ -10,7 +10,6 @@ from distutils.tests import support
@pytest.mark.usefixtures('save_env')
class TestInstallHeaders(
support.TempdirManager,
- support.LoggingSilencer,
):
def test_simple_run(self):
# we have two headers
diff --git a/distutils/tests/test_install_lib.py b/distutils/tests/test_install_lib.py
index a654a66a..cdf3fc97 100644
--- a/distutils/tests/test_install_lib.py
+++ b/distutils/tests/test_install_lib.py
@@ -15,7 +15,6 @@ from distutils.errors import DistutilsOptionError
@pytest.mark.usefixtures('save_env')
class TestInstallLib(
support.TempdirManager,
- support.LoggingSilencer,
):
def test_finalize_options(self):
dist = self.create_dist()[1]
@@ -94,7 +93,7 @@ class TestInstallLib(
inputs = cmd.get_inputs()
assert len(inputs) == 2, inputs
- def test_dont_write_bytecode(self):
+ def test_dont_write_bytecode(self, logs):
# makes sure byte_compile is not used
dist = self.create_dist()[1]
cmd = install_lib(dist)
@@ -108,4 +107,4 @@ class TestInstallLib(
finally:
sys.dont_write_bytecode = old_dont_write_bytecode
- assert 'byte-compiling is disabled' in self.logs[0][1] % self.logs[0][2]
+ assert 'byte-compiling is disabled' in logs.render()[0]
diff --git a/distutils/tests/test_install_scripts.py b/distutils/tests/test_install_scripts.py
index 0d17f11b..58313f28 100644
--- a/distutils/tests/test_install_scripts.py
+++ b/distutils/tests/test_install_scripts.py
@@ -8,7 +8,7 @@ from distutils.core import Distribution
from distutils.tests import support
-class TestInstallScripts(support.TempdirManager, support.LoggingSilencer):
+class TestInstallScripts(support.TempdirManager):
def test_default_settings(self):
dist = Distribution()
dist.command_obj["build"] = support.DummyCommand(build_scripts="/foo/bar")
diff --git a/distutils/tests/test_register.py b/distutils/tests/test_register.py
index 0a5765f1..d0b4cc7c 100644
--- a/distutils/tests/test_register.py
+++ b/distutils/tests/test_register.py
@@ -303,14 +303,13 @@ class TestRegister(BasePyPIRCCommandTestCase):
with pytest.raises(DistutilsSetupError):
cmd.run()
- def test_list_classifiers(self):
+ def test_list_classifiers(self, logs):
cmd = self._get_cmd()
cmd.list_classifiers = 1
cmd.run()
- results = self.get_logs(INFO)
- assert results == ['running check', 'xxx']
+ assert logs.render(INFO) == ['running check', 'xxx']
- def test_show_response(self):
+ def test_show_response(self, logs):
# test that the --show-response option return a well formatted response
cmd = self._get_cmd()
inputs = Inputs('1', 'tarek', 'y')
@@ -321,5 +320,5 @@ class TestRegister(BasePyPIRCCommandTestCase):
finally:
del register_module.input
- results = self.get_logs(INFO)
+ results = logs.render(INFO)
assert results[3] == 75 * '-' + '\nxxx\n' + 75 * '-'
diff --git a/distutils/tests/test_sdist.py b/distutils/tests/test_sdist.py
index b11fe7c4..da36bfcf 100644
--- a/distutils/tests/test_sdist.py
+++ b/distutils/tests/test_sdist.py
@@ -253,7 +253,7 @@ class TestSDist(BasePyPIRCCommandTestCase):
assert manifest == MANIFEST % {'sep': os.sep}
@pytest.mark.usefixtures('needs_zlib')
- def test_metadata_check_option(self):
+ def test_metadata_check_option(self, logs):
# testing the `medata-check` option
dist, cmd = self.get_cmd(metadata={})
@@ -262,18 +262,18 @@ class TestSDist(BasePyPIRCCommandTestCase):
cmd.ensure_finalized()
cmd.run()
warnings = [
- msg for msg in self.get_logs(WARN) if msg.startswith('warning: check:')
+ msg for msg in logs.render(WARN) if msg.startswith('warning: check:')
]
assert len(warnings) == 1
# trying with a complete set of metadata
- self.clear_logs()
+ logs.clear()
dist, cmd = self.get_cmd()
cmd.ensure_finalized()
cmd.metadata_check = 0
cmd.run()
warnings = [
- msg for msg in self.get_logs(WARN) if msg.startswith('warning: check:')
+ msg for msg in logs.render(WARN) if msg.startswith('warning: check:')
]
assert len(warnings) == 0
@@ -323,28 +323,28 @@ class TestSDist(BasePyPIRCCommandTestCase):
# the following tests make sure there is a nice error message instead
# of a traceback when parsing an invalid manifest template
- def _check_template(self, content):
+ def _check_template(self, content, logs):
dist, cmd = self.get_cmd()
os.chdir(self.tmp_dir)
self.write_file('MANIFEST.in', content)
cmd.ensure_finalized()
cmd.filelist = FileList()
cmd.read_template()
- warnings = self.get_logs(WARN)
+ warnings = logs.render(WARN)
assert len(warnings) == 1
- def test_invalid_template_unknown_command(self):
- self._check_template('taunt knights *')
+ def test_invalid_template_unknown_command(self, logs):
+ self._check_template('taunt knights *', logs)
- def test_invalid_template_wrong_arguments(self):
+ def test_invalid_template_wrong_arguments(self, logs):
# this manifest command takes one argument
- self._check_template('prune')
+ self._check_template('prune', logs)
@pytest.mark.skipif("platform.system() != 'Windows'")
- def test_invalid_template_wrong_path(self):
+ def test_invalid_template_wrong_path(self, logs):
# on Windows, trailing slashes are not allowed
# this used to crash instead of raising a warning: #8286
- self._check_template('include examples/')
+ self._check_template('include examples/', logs)
@pytest.mark.usefixtures('needs_zlib')
def test_get_file_list(self):
diff --git a/distutils/tests/test_spawn.py b/distutils/tests/test_spawn.py
index 5da49977..08a34ee2 100644
--- a/distutils/tests/test_spawn.py
+++ b/distutils/tests/test_spawn.py
@@ -17,7 +17,7 @@ from distutils.tests import support
import pytest
-class TestSpawn(support.TempdirManager, support.LoggingSilencer):
+class TestSpawn(support.TempdirManager):
@pytest.mark.skipif("os.name not in ('nt', 'posix')")
def test_spawn(self):
tmpdir = self.mkdtemp()
diff --git a/distutils/tests/test_upload.py b/distutils/tests/test_upload.py
index fb905b64..efd9e906 100644
--- a/distutils/tests/test_upload.py
+++ b/distutils/tests/test_upload.py
@@ -109,7 +109,7 @@ class TestUpload(BasePyPIRCCommandTestCase):
cmd.finalize_options()
assert cmd.password == 'xxx'
- def test_upload(self):
+ def test_upload(self, logs):
tmp = self.mkdtemp()
path = os.path.join(tmp, 'xxx')
self.write_file(path)
@@ -150,7 +150,7 @@ class TestUpload(BasePyPIRCCommandTestCase):
)
# The PyPI response body was echoed
- results = self.get_logs(INFO)
+ results = logs.render(INFO)
assert results[-1] == 75 * '-' + '\nxyzzy\n' + 75 * '-'
# bpo-32304: archives whose last byte was b'\r' were corrupted due to
@@ -178,11 +178,11 @@ class TestUpload(BasePyPIRCCommandTestCase):
assert int(headers['Content-length']) >= 2172
assert b'long description\r' in self.last_open.req.data
- def test_upload_fails(self):
+ def test_upload_fails(self, logs):
self.next_msg = "Not Found"
self.next_code = 404
with pytest.raises(DistutilsError):
- self.test_upload()
+ self.test_upload(logs)
@pytest.mark.parametrize(
'exception,expected,raised_exception',
@@ -196,7 +196,7 @@ class TestUpload(BasePyPIRCCommandTestCase):
),
],
)
- def test_wrong_exception_order(self, exception, expected, raised_exception):
+ def test_wrong_exception_order(self, exception, expected, raised_exception, logs):
tmp = self.mkdtemp()
path = os.path.join(tmp, 'xxx')
self.write_file(path)
@@ -213,6 +213,6 @@ class TestUpload(BasePyPIRCCommandTestCase):
cmd = upload(dist)
cmd.ensure_finalized()
cmd.run()
- results = self.get_logs(ERROR)
+ results = logs.render(ERROR)
assert expected in results[-1]
- self.clear_logs()
+ logs.clear()