Skip to content

Commit aa331ff

Browse files
committed
Invoke invalidate_caches in tests exhibiting refleaks.
1 parent c5fce57 commit aa331ff

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Lib/test/test_importlib/test_main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pickle
33
import unittest
44
import warnings
5+
import importlib
56
import importlib.metadata
67
import contextlib
78
from test.support import os_helper
@@ -37,6 +38,9 @@ def suppress_known_deprecation():
3738
class BasicTests(fixtures.DistInfoPkg, unittest.TestCase):
3839
version_pattern = r'\d+\.\d+(\.\d)?'
3940

41+
def tearDown(self):
42+
importlib.invalidate_caches()
43+
4044
def test_retrieves_version_of_self(self):
4145
dist = Distribution.from_name('distinfo-pkg')
4246
assert isinstance(dist.version, str)
@@ -75,6 +79,7 @@ def test_invalid_inputs_to_from_name(self, name):
7579

7680

7781
class ImportTests(fixtures.DistInfoPkg, unittest.TestCase):
82+
7883
def test_import_nonexistent_module(self):
7984
# Ensure that the MetadataPathFinder does not crash an import of a
8085
# non-existent module.

Lib/test/test_importlib/test_metadata_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class APITests(
3737
):
3838
version_pattern = r'\d+\.\d+(\.\d)?'
3939

40+
def tearDown(self):
41+
importlib.invalidate_caches()
42+
4043
def test_retrieves_version_of_self(self):
4144
pkg_version = version('egginfo-pkg')
4245
assert isinstance(pkg_version, str)

0 commit comments

Comments
 (0)