@@ -83,3 +83,184 @@ def _get_test_result(self, runner, test_name):
8383 (result for result in runner .test_results .test_results if result .get ("test_name" ) == test_name ),
8484 None
8585 )
86+
87+ def test_wildcard_01 (self ):
88+ """package.py unit tests are correctly found with a wildcard then run in a testing environment"""
89+ self .inject_python_repo ()
90+ context = ResolvedContext (["testing_obj" , "python" ])
91+ # This will get us more code coverage :)
92+ self .inject_python_repo ()
93+ runner = PackageTestRunner (
94+ package_request = "testing_obj" ,
95+ package_paths = context .package_paths ,
96+ )
97+
98+ test_names = runner .find_requested_test_names (["command_as_*" ])
99+ self .assertEqual (2 , len (test_names ))
100+
101+ for test_name in test_names :
102+ runner .run_test (test_name )
103+
104+ self .assertEqual (runner .test_results .num_tests , 2 )
105+
106+ self .assertEqual (
107+ self ._get_test_result (runner , "command_as_string_success" )["status" ],
108+ "success" ,
109+ "command_as_string_success did not succeed" ,
110+ )
111+ self .assertEqual (
112+ self ._get_test_result (runner , "command_as_string_fail" )["status" ],
113+ "failed" ,
114+ "command_as_string_fail did not fail" ,
115+ )
116+
117+ def test_wildcard_02 (self ):
118+ """
119+ package.py unit tests are correctly found with a wildcard + a package name then run
120+ in a testing environment
121+ """
122+ self .inject_python_repo ()
123+ context = ResolvedContext (["testing_obj" , "python" ])
124+ # This will get us more code coverage :)
125+ self .inject_python_repo ()
126+ runner = PackageTestRunner (
127+ package_request = "testing_obj" ,
128+ package_paths = context .package_paths ,
129+
130+ )
131+
132+ test_names = runner .find_requested_test_names (["command_as_*" , "check_car_ideas" ])
133+ self .assertEqual (3 , len (test_names ))
134+
135+ for test_name in test_names :
136+ runner .run_test (test_name )
137+
138+ self .assertEqual (runner .test_results .num_tests , 3 )
139+
140+ self .assertEqual (
141+ self ._get_test_result (runner , "check_car_ideas" )["status" ],
142+ "success" ,
143+ "check_car_ideas did not succeed" ,
144+ )
145+ self .assertEqual (
146+ self ._get_test_result (runner , "command_as_string_success" )["status" ],
147+ "success" ,
148+ "command_as_string_success did not succeed" ,
149+ )
150+ self .assertEqual (
151+ self ._get_test_result (runner , "command_as_string_fail" )["status" ],
152+ "failed" ,
153+ "command_as_string_fail did not fail" ,
154+ )
155+
156+ def test_wildcard_03 (self ):
157+ """
158+ package.py unit tests are correctly found with a wildcard equivalent to 'default' then run
159+ in a testing environment
160+ """
161+ self .inject_python_repo ()
162+ context = ResolvedContext (["testing_obj" , "python" ])
163+ # This will get us more code coverage :)
164+ self .inject_python_repo ()
165+ runner = PackageTestRunner (
166+ package_request = "testing_obj" ,
167+ package_paths = context .package_paths ,
168+
169+ )
170+
171+ test_names = runner .find_requested_test_names (["*" ])
172+ self .assertEqual (4 , len (test_names ))
173+
174+ for test_name in test_names :
175+ runner .run_test (test_name )
176+
177+ self .assertEqual (runner .test_results .num_tests , 4 )
178+
179+ self .assertEqual (
180+ self ._get_test_result (runner , "check_car_ideas" )["status" ],
181+ "success" ,
182+ "check_car_ideas did not succeed" ,
183+ )
184+ self .assertEqual (
185+ self ._get_test_result (runner , "move_meeting_to_noon" )["status" ],
186+ "failed" ,
187+ "move_meeting_to_noon did not fail" ,
188+ )
189+ self .assertEqual (
190+ self ._get_test_result (runner , "command_as_string_success" )["status" ],
191+ "success" ,
192+ "command_as_string_success did not succeed" ,
193+ )
194+ self .assertEqual (
195+ self ._get_test_result (runner , "command_as_string_fail" )["status" ],
196+ "failed" ,
197+ "command_as_string_fail did not fail" ,
198+ )
199+
200+ def test_wildcard_04 (self ):
201+ """
202+ package.py unit tests are correctly found with a wildcard which get all test starting by 'c' and
203+ the second letter is 'h' or 'o' then run in a testing environment
204+ """
205+ self .inject_python_repo ()
206+ context = ResolvedContext (["testing_obj" , "python" ])
207+ # This will get us more code coverage :)
208+ self .inject_python_repo ()
209+ runner = PackageTestRunner (
210+ package_request = "testing_obj" ,
211+ package_paths = context .package_paths ,
212+
213+ )
214+
215+ test_names = runner .find_requested_test_names (["c[ho]*" ])
216+ self .assertEqual (3 , len (test_names ))
217+
218+ for test_name in test_names :
219+ runner .run_test (test_name )
220+
221+ self .assertEqual (runner .test_results .num_tests , 3 )
222+
223+ self .assertEqual (
224+ self ._get_test_result (runner , "check_car_ideas" )["status" ],
225+ "success" ,
226+ "check_car_ideas did not succeed" ,
227+ )
228+ self .assertEqual (
229+ self ._get_test_result (runner , "command_as_string_success" )["status" ],
230+ "success" ,
231+ "command_as_string_success did not succeed" ,
232+ )
233+ self .assertEqual (
234+ self ._get_test_result (runner , "command_as_string_fail" )["status" ],
235+ "failed" ,
236+ "command_as_string_fail did not fail" ,
237+ )
238+
239+ def test_wildcard_05 (self ):
240+ """
241+ package.py unit tests are correctly found with a wildcard which get all test which is not starting by 'c'
242+ then run in a testing environment
243+ """
244+ self .inject_python_repo ()
245+ context = ResolvedContext (["testing_obj" , "python" ])
246+ # This will get us more code coverage :)
247+ self .inject_python_repo ()
248+ runner = PackageTestRunner (
249+ package_request = "testing_obj" ,
250+ package_paths = context .package_paths ,
251+
252+ )
253+
254+ test_names = runner .find_requested_test_names (["[!c]*" ])
255+ self .assertEqual (1 , len (test_names ))
256+
257+ for test_name in test_names :
258+ runner .run_test (test_name )
259+
260+ self .assertEqual (runner .test_results .num_tests , 1 )
261+
262+ self .assertEqual (
263+ self ._get_test_result (runner , "move_meeting_to_noon" )["status" ],
264+ "failed" ,
265+ "move_meeting_to_noon did not fail" ,
266+ )
0 commit comments