Skip to content

Commit 4fdcc45

Browse files
committed
Black!
1 parent fb04bc3 commit 4fdcc45

File tree

3 files changed

+49
-15
lines changed

3 files changed

+49
-15
lines changed

tests/test_core_functionality.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def test_skipped():
1414
assert False # This will not be executed.
1515

1616

17-
@upytest.skip("This test will be skipped with a when condition", skip_when=True)
17+
@upytest.skip(
18+
"This test will be skipped with a when condition", skip_when=True
19+
)
1820
def test_when_skipped():
1921
"""
2022
Test functions decorated with `@upytest.skip` and a truthy when condition
@@ -23,7 +25,10 @@ def test_when_skipped():
2325
assert False
2426

2527

26-
@upytest.skip("This test will NOT be skipped with a False-y when", skip_when=False)
28+
@upytest.skip(
29+
"This test will NOT be skipped with a False-y when",
30+
skip_when=False,
31+
)
2732
def test_when_not_skipped_passes():
2833
"""
2934
Test functions decorated with `@upytest.skip` and a falsey when condition
@@ -93,12 +98,17 @@ async def test_async_skipped():
9398
assert False # This will not be executed.
9499

95100

96-
@upytest.skip("This test will be skipped with a when condition", skip_when=True)
101+
@upytest.skip(
102+
"This test will be skipped with a when condition", skip_when=True
103+
)
97104
async def test_async_when_skipped():
98105
assert False # This will not be executed.
99106

100107

101-
@upytest.skip("This test will NOT be skipped with a False-y when", skip_when=False)
108+
@upytest.skip(
109+
"This test will NOT be skipped with a False-y when",
110+
skip_when=False,
111+
)
102112
async def test_async_when_not_skipped_passes():
103113
assert True, "This async test passes"
104114

tests/test_with_setup_teardown.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ async def setup():
1313

1414

1515
async def teardown():
16-
window.console.log("Teardown from async teardown function in module")
16+
window.console.log(
17+
"Teardown from async teardown function in module"
18+
)
1719

1820

1921
def test_with_local_setup_teardown_passes():

upytest.py

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)