@@ -305,3 +305,54 @@ def mock_addFailure(result, exc):
305
305
self .fail (formatted )
306
306
307
307
self .assertEqual (mock_world .test_thing .call_count , 2 )
308
+
309
+
310
+ def test_scenario_tag (self ):
311
+ from planterbox .feature import FeatureTestCase
312
+ from planterbox import step
313
+
314
+ test_feature = """Feature: A Scenario Tag Feature
315
+
316
+ Scenario: A Test Scenario.
317
+ Scenario Tag: math2
318
+ When I test a thing
319
+
320
+ Scenario: An Untagged Test Scenario.
321
+ When I test a thing
322
+ """
323
+
324
+ @step (r'I test a thing' )
325
+ def test_thing (test ):
326
+ pass
327
+
328
+ mock_world = Mock (
329
+ spec = ['test_thing' ],
330
+ return_value = None ,
331
+ )
332
+ mock_world .__name__ = 'mock'
333
+ mock_world .test_thing = step (r'I test a thing' )(Mock (
334
+ planterbox_patterns = [],
335
+ ))
336
+
337
+
338
+ def mock_addFailure (result , exc ):
339
+ self .exc_info = exc
340
+
341
+ mock_result = Mock (addFailure = Mock (side_effect = mock_addFailure ))
342
+
343
+ with patch ('planterbox.feature.import_module' ,
344
+ Mock (return_value = mock_world )):
345
+ test_case = FeatureTestCase (
346
+ feature_path = 'foobar.feature' ,
347
+ feature_text = test_feature ,
348
+ tag_list = ("math2" ,)
349
+ )
350
+
351
+ test_case .__module__ = 'mock'
352
+ test_case .run (mock_result )
353
+
354
+ if hasattr (self , 'exc_info' ):
355
+ formatted = test_case .formatTraceback (self .exc_info )
356
+ self .fail (formatted )
357
+
358
+ mock_world .test_thing .assert_called_once ()
0 commit comments