@@ -91,23 +91,46 @@ class WindowsRegistryFinderTests:
91
91
test_module = "spamham{}" .format (os .getpid ())
92
92
93
93
def test_find_spec_missing (self ):
94
- spec = self .machinery .WindowsRegistryFinder .find_spec ('spam' )
94
+ with self .assertWarnsRegex (
95
+ DeprecationWarning ,
96
+ r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
97
+ r"use site configuration instead\. Future versions of Python may "
98
+ r"not enable this finder by default\."
99
+ ):
100
+ spec = self .machinery .WindowsRegistryFinder .find_spec ('spam' )
95
101
self .assertIsNone (spec )
96
102
97
103
def test_module_found (self ):
98
104
with setup_module (self .machinery , self .test_module ):
99
- spec = self .machinery .WindowsRegistryFinder .find_spec (self .test_module )
105
+ with self .assertWarnsRegex (
106
+ DeprecationWarning ,
107
+ r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
108
+ r"use site configuration instead\. Future versions of Python may "
109
+ r"not enable this finder by default\."
110
+ ):
111
+ spec = self .machinery .WindowsRegistryFinder .find_spec (self .test_module )
100
112
self .assertIsNotNone (spec )
101
113
102
114
def test_module_not_found (self ):
103
115
with setup_module (self .machinery , self .test_module , path = "." ):
104
- spec = self .machinery .WindowsRegistryFinder .find_spec (self .test_module )
116
+ with self .assertWarnsRegex (
117
+ DeprecationWarning ,
118
+ r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
119
+ r"use site configuration instead\. Future versions of Python may "
120
+ r"not enable this finder by default\."
121
+ ):
122
+ spec = self .machinery .WindowsRegistryFinder .find_spec (self .test_module )
105
123
self .assertIsNone (spec )
106
124
107
125
def test_raises_deprecation_warning (self ):
108
126
# WindowsRegistryFinder is not meant to be instantiated, so the
109
127
# deprecation warning is raised in the 'find_spec' method instead.
110
- with self .assertWarns (DeprecationWarning ):
128
+ with self .assertWarnsRegex (
129
+ DeprecationWarning ,
130
+ r"importlib\.machinery\.WindowsRegistryFinder is deprecated; "
131
+ r"use site configuration instead\. Future versions of Python may "
132
+ r"not enable this finder by default\."
133
+ ):
111
134
self .machinery .WindowsRegistryFinder .find_spec ('spam' )
112
135
113
136
(Frozen_WindowsRegistryFinderTests ,
0 commit comments