File tree 1 file changed +13
-4
lines changed
1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ the tests for xkcd and wikipedia bots):
46
46
nargs = '*' ,
47
47
default = [],
48
48
help = 'bot(s) to exclude' )
49
+ parser .add_argument ('--error-on-no-init' ,
50
+ default = False ,
51
+ action = "store_true" ,
52
+ help = "whether to exit if a bot has tests which won't run due to no __init__.py" )
49
53
return parser .parse_args ()
50
54
51
55
@@ -76,15 +80,20 @@ def main():
76
80
77
81
bots_to_test = filter (lambda bot : bot not in options .exclude , specified_bots )
78
82
79
- # Should add a check here that __init__.py is absent if test_*.py is present?
80
-
81
83
# Codecov seems to work only when using loader.discover. It failed to
82
84
# capture line executions for functions like loader.loadTestFromModule
83
85
# or loader.loadTestFromNames.
84
86
top_level = "zulip_bots/zulip_bots/bots/"
85
87
loader = unittest .defaultTestLoader
86
- test_suites = [loader .discover (top_level + name , top_level_dir = top_level )
87
- for name in bots_to_test ]
88
+ test_suites = []
89
+ for name in bots_to_test :
90
+ try :
91
+ test_suites .append (loader .discover (top_level + name , top_level_dir = top_level ))
92
+ except ImportError as exception :
93
+ print (exception )
94
+ print ("This likely indicates that you need a '__init__.py' file in your bot directory." )
95
+ if options .error_on_no_init :
96
+ sys .exit (1 )
88
97
89
98
def filter_tests (tests ):
90
99
# type: (Union[TestSuite, TestCase]) -> TestSuite
You can’t perform that action at this time.
0 commit comments