summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cmd_line_script.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_cmd_line_script.py')
-rw-r--r--Lib/test/test_cmd_line_script.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index b2be9b1..e7c6351 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -127,7 +127,10 @@ class CmdLineTest(unittest.TestCase):
print(printed_package)
print(printed_argv0)
print(printed_cwd)
- self.assertIn(printed_loader.encode('utf-8'), data)
+ expected = printed_loader.encode('utf-8')
+ idx = expected.find(b"at 0x")
+ expected = expected[:idx]
+ self.assertIn(expected, data)
self.assertIn(printed_file.encode('utf-8'), data)
self.assertIn(printed_package.encode('utf-8'), data)
self.assertIn(printed_argv0.encode('utf-8'), data)
@@ -138,9 +141,8 @@ class CmdLineTest(unittest.TestCase):
expected_argv0, expected_path0,
expected_package, expected_loader,
*cmd_line_switches):
- if not __debug__:
- cmd_line_switches += ('-' + 'O' * sys.flags.optimize,)
- run_args = cmd_line_switches + (script_name,) + tuple(example_args)
+ run_args = [*support.optim_args_from_interpreter_flags(),
+ *cmd_line_switches, script_name, *example_args]
rc, out, err = assert_python_ok(*run_args, __isolated=False)
self._check_output(script_name, rc, out + err, expected_file,
expected_argv0, expected_path0,
@@ -159,6 +161,8 @@ class CmdLineTest(unittest.TestCase):
def test_dash_c_loader(self):
rc, out, err = assert_python_ok("-c", "print(__loader__)")
expected = repr(importlib.machinery.BuiltinImporter).encode("utf-8")
+ idx = expected.find(b"at 0x")
+ expected = expected[:idx]
self.assertIn(expected, out)
def test_stdin_loader(self):
@@ -172,6 +176,8 @@ class CmdLineTest(unittest.TestCase):
finally:
out = kill_python(p)
expected = repr(importlib.machinery.BuiltinImporter).encode("utf-8")
+ idx = expected.find(b"at 0x")
+ expected = expected[:idx]
self.assertIn(expected, out)
@contextlib.contextmanager