Skip to content

Commit

Permalink
add diagnostics to ok test (#148)
Browse files Browse the repository at this point in the history
Co-authored-by: Cody D'Ambrosio <[email protected]>
  • Loading branch information
codambro and Cody D'Ambrosio authored Jan 26, 2025
1 parent 9ef7f66 commit 89762f4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Contributors
* Allison Karlitskaya
* Andrew McNamara
* Chris Clarke
* Cody D'Ambrosio
* Erik Cederstrand
* Marc Abramowitz
* Mark E. Hamilton
Expand Down
1 change: 1 addition & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Version 3.2, To Be Released
* Add support for Python 3.11.
* Add support for Python 3.12.
* Add support for Python 3.13.
* Add support for adding diagnostics to ok test

Version 3.1, Released December 29, 2021
---------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion src/tap/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ def _track(self, class_name):
if self.combined:
self.combined_test_cases_seen.append(class_name)

def add_ok(self, class_name, description, directive=""):
def add_ok(self, class_name, description, directive="", diagnostics=None):
result = Result(
ok=True,
number=self._get_next_line_number(class_name),
description=description,
diagnostics=diagnostics,
directive=Directive(directive),
)
self._add_line(class_name, result)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ def test_sanitizes_tap_file_path(self):
file_path = tracker._get_tap_file_path("an awful \\ testcase / name\n")
self.assertEqual("an-awful---testcase---name-.tap", file_path)

def test_adds_ok_with_diagnostics(self):
tracker = Tracker()
tracker.add_ok("FakeTestCase", "a description", diagnostics="# more info\n")
line = tracker._test_cases["FakeTestCase"][0]
self.assertEqual("# more info\n", line.diagnostics)

def test_adds_not_ok_with_diagnostics(self):
tracker = Tracker()
tracker.add_not_ok("FakeTestCase", "a description", diagnostics="# more info\n")
Expand Down

0 comments on commit 89762f4

Please sign in to comment.