diff --git a/Lib/packaging/tests/test_uninstall.py b/Lib/packaging/tests/test_uninstall.py index 578b10db580..d5a2521d7c4 100644 --- a/Lib/packaging/tests/test_uninstall.py +++ b/Lib/packaging/tests/test_uninstall.py @@ -1,6 +1,7 @@ """Tests for the uninstall command.""" import os import sys +from io import StringIO from packaging.database import disable_cache, enable_cache from packaging.run import main @@ -79,7 +80,12 @@ class UninstallTestCase(support.TempdirManager, if not dirname: dirname = self.make_dist(name, **kw) os.chdir(dirname) - dist = self.run_setup('install_dist', '--prefix=' + self.root_dir) + old_out = sys.stdout + sys.stderr = StringIO() + try: + dist = self.run_setup('install_dist', '--prefix=' + self.root_dir) + finally: + sys.sterr = old_out install_lib = self.get_path(dist, 'purelib') return dist, install_lib