From 97d18c2cdc93a1eba23858bb9840e58a88028c78 Mon Sep 17 00:00:00 2001 From: ahgamut <41098605+ahgamut@users.noreply.github.com> Date: Fri, 13 May 2022 22:14:45 +0530 Subject: [PATCH] changes for MODE=tiny unittest checks if a directory is a package by looking for an __init__.py inside. In MODE=tiny we only have a .pyc file. --- third_party/python/Lib/test/test_sys.py | 2 ++ third_party/python/Lib/test/test_tempfile.py | 2 +- third_party/python/Lib/unittest/loader.py | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/third_party/python/Lib/test/test_sys.py b/third_party/python/Lib/test/test_sys.py index f05cf6066..d92f05107 100644 --- a/third_party/python/Lib/test/test_sys.py +++ b/third_party/python/Lib/test/test_sys.py @@ -200,6 +200,7 @@ class SysModuleTest(unittest.TestCase): self.assertEqual(sys.getrecursionlimit(), 10000) sys.setrecursionlimit(oldlimit) + @unittest.skipIf("tiny" in cosmo.MODE, "") def test_recursionlimit_recovery(self): if hasattr(sys, 'gettrace') and sys.gettrace(): self.skipTest('fatal error if run with a trace function') @@ -259,6 +260,7 @@ class SysModuleTest(unittest.TestCase): finally: sys.setrecursionlimit(oldlimit) + @unittest.skipIf("tiny" in cosmo.MODE, "") def test_recursionlimit_fatalerror(self): # A fatal error occurs if a second recursion limit is hit when recovering # from a first one. diff --git a/third_party/python/Lib/test/test_tempfile.py b/third_party/python/Lib/test/test_tempfile.py index 888a1c62c..faef2d300 100644 --- a/third_party/python/Lib/test/test_tempfile.py +++ b/third_party/python/Lib/test/test_tempfile.py @@ -474,7 +474,7 @@ class TestMkstempInner(TestBadTempdir, BaseTestCase): # effect. The core of this test is therefore in # tf_inherit_check.py, which see. tester = os.path.join(os.path.dirname(os.path.abspath(me)), - "tf_inherit_check.py") + "tf_inherit_check.pyc") # On Windows a spawn* /path/ with embedded spaces shouldn't be quoted, # but an arg with embedded spaces should be decorated with double diff --git a/third_party/python/Lib/unittest/loader.py b/third_party/python/Lib/unittest/loader.py index e860debc0..0282f54e5 100644 --- a/third_party/python/Lib/unittest/loader.py +++ b/third_party/python/Lib/unittest/loader.py @@ -283,7 +283,9 @@ class TestLoader(object): if os.path.isdir(os.path.abspath(start_dir)): start_dir = os.path.abspath(start_dir) if start_dir != top_level_dir: - is_not_importable = not os.path.isfile(os.path.join(start_dir, '__init__.py')) + is_not_importable_py = not os.path.isfile(os.path.join(start_dir, '__init__.py')) + is_not_importable_pyc = not os.path.isfile(os.path.join(start_dir, '__init__.pyc')) + is_not_importable = is_not_importable_py and is_not_importable_pyc else: # support for discovery from dotted module names try: