Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
339f260
gh-108927: Do not remove tested modules from sys.modules
serhiy-storchaka Sep 5, 2023
e52be9b
Update NEWS entry.
serhiy-storchaka Sep 5, 2023
68c014e
Fix unloading the newly imported modules after testing.
serhiy-storchaka Sep 6, 2023
c1ad70c
Merge branch 'main' into regretest-no-remove-test-module
serhiy-storchaka Sep 12, 2023
3f25ab4
Add tests.
serhiy-storchaka Sep 12, 2023
7673248
Update Misc/NEWS.d/next/Tests/2023-09-05-20-46-35.gh-issue-108927.Tpw…
serhiy-storchaka Sep 12, 2023
5df4c8b
Move save/unload modules down in single.py.
serhiy-storchaka Sep 13, 2023
eb7766b
Merge branch 'main' into regretest-no-remove-test-module
serhiy-storchaka Sep 13, 2023
0eae535
Refactoring.
serhiy-storchaka Sep 13, 2023
66437b5
Remove also attributes from parent modules.
serhiy-storchaka Sep 13, 2023
8470b33
Merge branch 'main' into regretest-no-remove-test-module
serhiy-storchaka Oct 14, 2023
544c068
Merge branch 'main' into regretest-no-remove-test-module
serhiy-storchaka Nov 27, 2023
1e7ea34
Merge branch 'main' into regretest-no-remove-test-module
serhiy-storchaka Nov 28, 2023
56621ab
Only unload modules if run tests sequentially.
serhiy-storchaka Nov 28, 2023
ba5597a
Apply suggestions from code review
serhiy-storchaka Dec 1, 2023
d025e22
Merge branch 'main' into regretest-no-remove-test-module
serhiy-storchaka Dec 4, 2023
1aae341
Add a comment.
serhiy-storchaka Dec 4, 2023
017f01d
Test that test modules are really unloaded.
serhiy-storchaka Dec 4, 2023
5086405
Merge remote-tracking branch 'refs/remotes/origin/regretest-no-remove…
serhiy-storchaka Dec 4, 2023
b3ea8fa
Update Lib/test/test_regrtest.py
serhiy-storchaka Dec 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into regretest-no-remove-test-module
  • Loading branch information
serhiy-storchaka committed Oct 14, 2023
commit 8470b3325e7f256a67978cd5ad3ad57cb1a23ce8
99 changes: 99 additions & 0 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,105 @@ def test_import_from_tests(self):
output = self.run_python(args)
self.check_executed_tests(output, tests, stats=3)

def check_add_python_opts(self, option):
# --fast-ci and --slow-ci add "-u -W default -bb -E" options to Python
code = textwrap.dedent(r"""
import sys
import unittest
from test import support
try:
from _testinternalcapi import get_config
except ImportError:
get_config = None

# WASI/WASM buildbots don't use -E option
use_environment = (support.is_emscripten or support.is_wasi)

class WorkerTests(unittest.TestCase):
@unittest.skipUnless(get_config is None, 'need get_config()')
def test_config(self):
config = get_config()['config']
# -u option
self.assertEqual(config['buffered_stdio'], 0)
# -W default option
self.assertTrue(config['warnoptions'], ['default'])
# -bb option
self.assertTrue(config['bytes_warning'], 2)
# -E option
self.assertTrue(config['use_environment'], use_environment)

def test_python_opts(self):
# -u option
self.assertTrue(sys.__stdout__.write_through)
self.assertTrue(sys.__stderr__.write_through)

# -W default option
self.assertTrue(sys.warnoptions, ['default'])

# -bb option
self.assertEqual(sys.flags.bytes_warning, 2)

# -E option
self.assertEqual(not sys.flags.ignore_environment,
use_environment)
""")
testname = self.create_test(code=code)

# Use directly subprocess to control the exact command line
cmd = [sys.executable,
"-m", "test", option,
f'--testdir={self.tmptestdir}',
testname]
proc = subprocess.run(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True)
self.assertEqual(proc.returncode, 0, proc)

def test_add_python_opts(self):
for opt in ("--fast-ci", "--slow-ci"):
with self.subTest(opt=opt):
self.check_add_python_opts(opt)

# gh-76319: Raising SIGSEGV on Android may not cause a crash.
@unittest.skipIf(support.is_android,
'raising SIGSEGV on Android is unreliable')
def test_worker_output_on_failure(self):
try:
from faulthandler import _sigsegv
except ImportError:
self.skipTest("need faulthandler._sigsegv")

code = textwrap.dedent(r"""
import faulthandler
import unittest
from test import support

class CrashTests(unittest.TestCase):
def test_crash(self):
print("just before crash!", flush=True)

with support.SuppressCrashReport():
faulthandler._sigsegv(True)
""")
testname = self.create_test(code=code)

# Sanitizers must not handle SIGSEGV (ex: for test_enable_fd())
env = dict(os.environ)
option = 'handle_segv=0'
support.set_sanitizer_env_var(env, option)

output = self.run_tests("-j1", testname,
exitcode=EXITCODE_BAD_TEST,
env=env)
self.check_executed_tests(output, testname,
failed=[testname],
stats=0, parallel=True)
if not support.MS_WINDOWS:
exitcode = -int(signal.SIGSEGV)
self.assertIn(f"Exit code {exitcode} (SIGSEGV)", output)
self.check_line(output, "just before crash!", full=True, regex=False)


class TestUtils(unittest.TestCase):
def test_format_duration(self):
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.