bpo-33944: site: Add site-packages tracing in verbose mode (GH-12110)

This commit is contained in:
native-api 2020-06-12 09:20:11 +03:00 committed by GitHub
parent ddef3bdc7b
commit 2145c8c972
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 0 deletions

View file

@ -13,6 +13,7 @@
import builtins
import encodings
import glob
import io
import os
import re
import shutil
@ -320,6 +321,14 @@ def test_no_home_directory(self):
mock_addsitedir.assert_not_called()
self.assertFalse(known_paths)
def test_trace(self):
message = "bla-bla-bla"
for verbose, out in (True, message + "\n"), (False, ""):
with mock.patch('sys.flags', mock.Mock(verbose=verbose)), \
mock.patch('sys.stderr', io.StringIO()):
site._trace(message)
self.assertEqual(sys.stderr.getvalue(), out)
class PthFile(object):
"""Helper class for handling testing of .pth files"""