Skip to content

Commit

Permalink
Stop parsing the test tree when reaching a method (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuheiktgw authored Jul 27, 2021
1 parent 01bdf3b commit 67780e7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions nose_launchable/manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from types import FunctionType
from inspect import isfunction, ismethod
from types import ModuleType

from nose.case import Test
Expand Down Expand Up @@ -45,11 +45,12 @@ def dfs(suite):
if not empty:
return suite

# 1. If type(suite) is Test the search reaches at the bottom
# 2. If type(suite.context) is function, the test is a generator and stop parsing it there to avoid executing it
if type(suite) is Test or type(getattr(suite, "context", None)) is FunctionType:
context = getattr(suite, "context", None)
# 1. If type(suite) is Test, the search reaches at the bottom
# 2. If context is function or method, the search should stop there to avoid executing it.
# It is most likely a test generator.
if type(suite) is Test or isfunction(context) or ismethod(context):
empty = False

return suite

suite._tests = [dfs(t) for t in suite]
Expand Down

0 comments on commit 67780e7

Please sign in to comment.