From ac1ee1badade69d5cd6d8b9112281f121183e7c0 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 5 Jun 2018 09:40:45 -0700 Subject: [PATCH] bpo-33755: Fix importlib.resources isolation tests (#7412) --- Lib/test/test_importlib/test_resource.py | 6 +++++- Lib/test/test_importlib/util.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_importlib/test_resource.py b/Lib/test/test_importlib/test_resource.py index b07686032e0..f88d92d1546 100644 --- a/Lib/test/test_importlib/test_resource.py +++ b/Lib/test/test_importlib/test_resource.py @@ -2,7 +2,7 @@ import sys import unittest from . import data01 -from . import zipdata02 +from . import zipdata01, zipdata02 from . import util from importlib import resources, import_module @@ -109,6 +109,10 @@ class ResourceFromZipsTest(util.ZipSetupBase, unittest.TestCase): set(resources.contents('ziptestdata.two')), {'__init__.py', 'resource2.txt'}) + +class SubdirectoryResourceFromZipsTest(util.ZipSetupBase, unittest.TestCase): + ZIP_MODULE = zipdata01 # type: ignore + def test_is_submodule_resource(self): submodule = import_module('ziptestdata.subdirectory') self.assertTrue( diff --git a/Lib/test/test_importlib/util.py b/Lib/test/test_importlib/util.py index 7b07b046a58..b0badebc2b8 100644 --- a/Lib/test/test_importlib/util.py +++ b/Lib/test/test_importlib/util.py @@ -549,6 +549,10 @@ class ZipSetupBase: except AttributeError: pass + def setUp(self): + modules = support.modules_setup() + self.addCleanup(support.modules_cleanup, *modules) + class ZipSetup(ZipSetupBase): ZIP_MODULE = zipdata01 # type: ignore