77from tap .tests import TestCase
88from tap .tracker import Tracker
99
10+ try :
11+ import yaml
12+ from more_itertools import peekable # noqa
13+
14+ have_yaml = True
15+ except ImportError :
16+ have_yaml = False
17+
1018
1119class TestTracker (TestCase ):
1220 def _make_header (self , test_case ):
@@ -295,8 +303,6 @@ def test_adds_not_ok_with_diagnostics(self):
295303 line = tracker ._test_cases ["FakeTestCase" ][0 ]
296304 self .assertEqual ("# more info\n " , line .diagnostics )
297305
298- @mock .patch ("tap.tracker.ENABLE_VERSION_13" , True )
299- @mock .patch ("tap.line.LOAD_YAML" , True )
300306 def test_adds_ok_with_yaml_block (self ):
301307 tracker = Tracker ()
302308 tracker .add_ok (
@@ -308,10 +314,11 @@ def test_adds_ok_with_yaml_block(self):
308314""" ,
309315 )
310316 line = tracker ._test_cases ["FakeTestCase" ][0 ]
311- self .assertEqual ("test_message" , line .yaml_block ["message" ])
317+ if have_yaml :
318+ self .assertEqual ("test_message" , line .yaml_block ["message" ])
319+ else :
320+ self .assertIsNone (line .yaml_block )
312321
313- @mock .patch ("tap.tracker.ENABLE_VERSION_13" , True )
314- @mock .patch ("tap.line.LOAD_YAML" , True )
315322 def test_adds_not_ok_with_yaml_block (self ):
316323 tracker = Tracker ()
317324 tracker .add_not_ok (
@@ -323,7 +330,10 @@ def test_adds_not_ok_with_yaml_block(self):
323330""" ,
324331 )
325332 line = tracker ._test_cases ["FakeTestCase" ][0 ]
326- self .assertEqual ("test_message" , line .yaml_block ["message" ])
333+ if have_yaml :
334+ self .assertEqual ("test_message" , line .yaml_block ["message" ])
335+ else :
336+ self .assertIsNone (line .yaml_block )
327337
328338 def test_header_displayed_by_default (self ):
329339 tracker = Tracker ()
0 commit comments