@@ -89,7 +89,9 @@ def import_module(module_path):
8989 Import a module from a given file path, in a way that works with both
9090 MicroPython and Pyodide.
9191 """
92- dotted_path = str (module_path ).replace ("/" , "." ).replace (".py" , "" )
92+ dotted_path = (
93+ str (module_path ).replace ("/" , "." ).replace (".py" , "" )
94+ )
9395 dotted_path = dotted_path .lstrip ("." )
9496 module = __import__ (dotted_path )
9597 for part in dotted_path .split ("." )[1 :]:
@@ -134,7 +136,9 @@ def __init__(self, test_function, module_name, test_name):
134136 self .test_name = test_name
135137 self .status = PENDING # the initial state of the test.
136138 self .traceback = None # to contain details of any failure.
137- self .reason = None # to contain the reason for skipping the test.
139+ self .reason = (
140+ None # to contain the reason for skipping the test.
141+ )
138142
139143 async def run (self ):
140144 """
@@ -221,7 +225,9 @@ def limit_tests_to(self, test_names):
221225 """
222226 Limit the tests run to the provided test_names list of names.
223227 """
224- self ._tests = [t for t in self ._tests if t .test_name in test_names ]
228+ self ._tests = [
229+ t for t in self ._tests if t .test_name in test_names
230+ ]
225231
226232 async def run (self ):
227233 """
@@ -264,7 +270,11 @@ def gather_conftest_functions(conftest_path, target):
264270 )
265271 conftest = import_module (conftest_path )
266272 setup = conftest .setup if hasattr (conftest , "setup" ) else None
267- teardown = conftest .teardown if hasattr (conftest , "teardown" ) else None
273+ teardown = (
274+ conftest .teardown
275+ if hasattr (conftest , "teardown" )
276+ else None
277+ )
268278 return setup , teardown
269279 return None , None
270280
@@ -292,16 +302,24 @@ def discover(targets, pattern, setup=None, teardown=None):
292302 result = []
293303 for target in targets :
294304 if "::" in target :
295- conftest_path = Path (target .split ("::" )[0 ]).parent / "conftest.py"
296- setup , teardown = gather_conftest_functions (conftest_path , target )
305+ conftest_path = (
306+ Path (target .split ("::" )[0 ]).parent / "conftest.py"
307+ )
308+ setup , teardown = gather_conftest_functions (
309+ conftest_path , target
310+ )
297311 module_path , test_names = target .split ("::" )
298312 module_instance = import_module (module_path )
299- module = TestModule (module_path , module_instance , setup , teardown )
313+ module = TestModule (
314+ module_path , module_instance , setup , teardown
315+ )
300316 module .limit_tests_to (test_names .split ("," ))
301317 result .append (module )
302318 elif os .path .isdir (target ):
303319 conftest_path = Path (target ) / "conftest.py"
304- setup , teardown = gather_conftest_functions (conftest_path , target )
320+ setup , teardown = gather_conftest_functions (
321+ conftest_path , target
322+ )
305323 for module_path in Path (target ).rglob (pattern ):
306324 module_instance = import_module (module_path )
307325 module = TestModule (
@@ -310,9 +328,13 @@ def discover(targets, pattern, setup=None, teardown=None):
310328 result .append (module )
311329 else :
312330 conftest_path = Path (target ).parent / "conftest.py"
313- setup , teardown = gather_conftest_functions (conftest_path , target )
331+ setup , teardown = gather_conftest_functions (
332+ conftest_path , target
333+ )
314334 module_instance = import_module (target )
315- module = TestModule (target , module_instance , setup , teardown )
335+ module = TestModule (
336+ target , module_instance , setup , teardown
337+ )
316338 result .append (module )
317339 return result
318340
0 commit comments