Skip to content

Commit 730e5f4

Browse files
author
Cody D'Ambrosio
committed
add unit tests
1 parent e7a1694 commit 730e5f4

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

tests/test_line.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,14 @@ def test_str_directive(self):
3838
self.assertEqual("ok 44 passing # SKIP a reason", str(result))
3939

4040
def test_str_diagnostics(self):
41-
result = Result(False, 43, "failing", diagnostics="# more info")
42-
self.assertEqual("not ok 43 failing\n# more info", str(result))
41+
result = Result(False, 45, "failing", diagnostics="# more info")
42+
self.assertEqual("not ok 45 failing\n# more info", str(result))
43+
44+
def test_yaml_block(self):
45+
raw_yaml_block = """\
46+
message: test_message
47+
severity: fail
48+
"""
49+
result = Result(False, 46, "passing", None, None,
50+
raw_yaml_block=raw_yaml_block)
51+
self.assertEqual(result.yaml_block["message"], "test_message")

tests/test_tracker.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,24 @@ def test_adds_not_ok_with_diagnostics(self):
295295
line = tracker._test_cases["FakeTestCase"][0]
296296
self.assertEqual("# more info\n", line.diagnostics)
297297

298+
def test_adds_ok_with_yaml_block(self):
299+
tracker = Tracker()
300+
tracker.add_ok("FakeTestCase", "a description", raw_yaml_block="""\
301+
message: test_message
302+
severity: pass
303+
""")
304+
line = tracker._test_cases["FakeTestCase"][0]
305+
self.assertEqual("test_message", line.yaml_block["message"])
306+
307+
def test_adds_not_ok_with_yaml_block(self):
308+
tracker = Tracker()
309+
tracker.add_not_ok("FakeTestCase", "a description", raw_yaml_block="""\
310+
message: test_message
311+
severity: fail
312+
""")
313+
line = tracker._test_cases["FakeTestCase"][0]
314+
self.assertEqual("test_message", line.yaml_block["message"])
315+
298316
def test_header_displayed_by_default(self):
299317
tracker = Tracker()
300318
self.assertTrue(tracker.header)

0 commit comments

Comments
 (0)