Skip to content

Commit f2f7cf4

Browse files
committed
Fix mark_class decorator to work in all cases
The 'mark_class' decorator assumed that all test functions started with 'test_' which is the common naming convention these days. The roundup codebase predates many of the current common conventions though though, so many tests don't include the underscore. We now correctly check for any test function starting with 'test' and also ensure the 'mark_class' will also work with functions as well as classes. This has been tested will all package dependencies missing, and all the tests correctly skip. All the tests also pass a full test run without any tests being skipped. A smattering of other runs of individual test files and enabled dependencies seem to indicate that all skipping should work as expected now.
1 parent d728121 commit f2f7cf4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/pytest_patcher.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ def copy_func(f):
2424
closure=f.func_closure)
2525

2626
def mark(cls):
27+
if isinstance(cls, types.FunctionType):
28+
return marker(copy_func(cls))
29+
2730
for method in dir(cls):
28-
if method.startswith('test_'):
31+
if method.startswith('test'):
2932
f = copy_func(getattr(cls, method))
3033
setattr(cls, method, marker(f))
3134
return cls

0 commit comments

Comments
 (0)