@@ -89,8 +89,7 @@ def test_is_package(self):
8989 ) = util .test_both (LoaderTests , machinery = machinery )
9090
9191class MultiPhaseExtensionModuleTests (abc .LoaderTests ):
92- """Test loading extension modules with multi-phase initialization (PEP 489)
93- """
92+ # Test loading extension modules with multi-phase initialization (PEP 489).
9493
9594 def setUp (self ):
9695 self .name = '_testmultiphase'
@@ -101,13 +100,13 @@ def setUp(self):
101100 self .name , self .spec .origin )
102101
103102 def load_module (self ):
104- ''' Load the module from the test extension'''
103+ # Load the module from the test extension.
105104 with warnings .catch_warnings ():
106105 warnings .simplefilter ("ignore" , DeprecationWarning )
107106 return self .loader .load_module (self .name )
108107
109108 def load_module_by_name (self , fullname ):
110- ''' Load a module from the test extension by name'''
109+ # Load a module from the test extension by name.
111110 origin = self .spec .origin
112111 loader = self .machinery .ExtensionFileLoader (fullname , origin )
113112 spec = importlib .util .spec_from_loader (fullname , loader )
@@ -125,7 +124,7 @@ def load_module_by_name(self, fullname):
125124 test_state_after_failure = None
126125
127126 def test_module (self ):
128- ''' Test loading an extension module'''
127+ # Test loading an extension module.
129128 with util .uncache (self .name ):
130129 module = self .load_module ()
131130 for attr , value in [('__name__' , self .name ),
@@ -139,7 +138,7 @@ def test_module(self):
139138 self .machinery .ExtensionFileLoader )
140139
141140 def test_functionality (self ):
142- ''' Test basic functionality of stuff defined in an extension module'''
141+ # Test basic functionality of stuff defined in an extension module.
143142 with util .uncache (self .name ):
144143 module = self .load_module ()
145144 self .assertIsInstance (module , types .ModuleType )
@@ -159,15 +158,15 @@ def test_functionality(self):
159158 self .assertEqual (module .str_const , 'something different' )
160159
161160 def test_reload (self ):
162- ''' Test that reload didn't re-set the module's attributes'''
161+ # Test that reload didn't re-set the module's attributes.
163162 with util .uncache (self .name ):
164163 module = self .load_module ()
165164 ex_class = module .Example
166165 importlib .reload (module )
167166 self .assertIs (ex_class , module .Example )
168167
169168 def test_try_registration (self ):
170- ''' Assert that the PyState_{Find,Add,Remove}Module C API doesn't work'''
169+ # Assert that the PyState_{Find,Add,Remove}Module C API doesn't work.
171170 module = self .load_module ()
172171 with self .subTest ('PyState_FindModule' ):
173172 self .assertEqual (module .call_state_registration_func (0 ), None )
@@ -179,65 +178,65 @@ def test_try_registration(self):
179178 module .call_state_registration_func (2 )
180179
181180 def test_load_submodule (self ):
182- ''' Test loading a simulated submodule'''
181+ # Test loading a simulated submodule.
183182 module = self .load_module_by_name ('pkg.' + self .name )
184183 self .assertIsInstance (module , types .ModuleType )
185184 self .assertEqual (module .__name__ , 'pkg.' + self .name )
186185 self .assertEqual (module .str_const , 'something different' )
187186
188187 def test_load_short_name (self ):
189- ''' Test loading module with a one-character name'''
188+ # Test loading module with a one-character name.
190189 module = self .load_module_by_name ('x' )
191190 self .assertIsInstance (module , types .ModuleType )
192191 self .assertEqual (module .__name__ , 'x' )
193192 self .assertEqual (module .str_const , 'something different' )
194193 self .assertNotIn ('x' , sys .modules )
195194
196195 def test_load_twice (self ):
197- ''' Test that 2 loads result in 2 module objects'''
196+ # Test that 2 loads result in 2 module objects.
198197 module1 = self .load_module_by_name (self .name )
199198 module2 = self .load_module_by_name (self .name )
200199 self .assertIsNot (module1 , module2 )
201200
202201 def test_unloadable (self ):
203- ''' Test nonexistent module'''
202+ # Test nonexistent module.
204203 name = 'asdfjkl;'
205204 with self .assertRaises (ImportError ) as cm :
206205 self .load_module_by_name (name )
207206 self .assertEqual (cm .exception .name , name )
208207
209208 def test_unloadable_nonascii (self ):
210- ''' Test behavior with nonexistent module with non-ASCII name'''
209+ # Test behavior with nonexistent module with non-ASCII name.
211210 name = 'fo\xf3 '
212211 with self .assertRaises (ImportError ) as cm :
213212 self .load_module_by_name (name )
214213 self .assertEqual (cm .exception .name , name )
215214
216215 def test_nonmodule (self ):
217- ''' Test returning a non-module object from create works'''
216+ # Test returning a non-module object from create works.
218217 name = self .name + '_nonmodule'
219218 mod = self .load_module_by_name (name )
220219 self .assertNotEqual (type (mod ), type (unittest ))
221220 self .assertEqual (mod .three , 3 )
222221
223222 # issue 27782
224223 def test_nonmodule_with_methods (self ):
225- ''' Test creating a non-module object with methods defined'''
224+ # Test creating a non-module object with methods defined.
226225 name = self .name + '_nonmodule_with_methods'
227226 mod = self .load_module_by_name (name )
228227 self .assertNotEqual (type (mod ), type (unittest ))
229228 self .assertEqual (mod .three , 3 )
230229 self .assertEqual (mod .bar (10 , 1 ), 9 )
231230
232231 def test_null_slots (self ):
233- ''' Test that NULL slots aren't a problem'''
232+ # Test that NULL slots aren't a problem.
234233 name = self .name + '_null_slots'
235234 module = self .load_module_by_name (name )
236235 self .assertIsInstance (module , types .ModuleType )
237236 self .assertEqual (module .__name__ , name )
238237
239238 def test_bad_modules (self ):
240- ''' Test SystemError is raised for misbehaving extensions'''
239+ # Test SystemError is raised for misbehaving extensions.
241240 for name_base in [
242241 'bad_slot_large' ,
243242 'bad_slot_negative' ,
@@ -261,9 +260,9 @@ def test_bad_modules(self):
261260 self .load_module_by_name (name )
262261
263262 def test_nonascii (self ):
264- ''' Test that modules with non-ASCII names can be loaded'''
263+ # Test that modules with non-ASCII names can be loaded.
265264 # punycode behaves slightly differently in some-ASCII and no-ASCII
266- # cases, so test both
265+ # cases, so test both.
267266 cases = [
268267 (self .name + '_zkou\u0161 ka_na\u010d ten\xed ' , 'Czech' ),
269268 ('\uff3f \u30a4 \u30f3 \u30dd \u30fc \u30c8 \u30c6 \u30b9 \u30c8 ' ,
0 commit comments