Skip to content

Commit c986e98

Browse files
committed
add segment_total_distance unit tests
1 parent 81dd687 commit c986e98

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_stringbuilder.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,3 +466,25 @@ def mock_isatty():
466466
coord1, coord2, coord3, 1.0, nocolor=True
467467
)
468468
assert res == "(0,0) (1,1) (2,2): QCURVE 1.00 units"
469+
470+
471+
def test_segment_total_distance_default(monkeypatch):
472+
# mock tty
473+
def mock_isatty():
474+
return True
475+
476+
# apply the monkeypatch for sys.stdout.isatty()
477+
monkeypatch.setattr(pathins.stringbuilder, "IS_A_TTY", mock_isatty)
478+
res = pathins.stringbuilder.segment_total_distance(1.0)
479+
assert res == "\033[1mTotal\033[0m: 1.00 units"
480+
481+
482+
def test_segment_total_distance_nocolor(monkeypatch):
483+
# mock tty
484+
def mock_isatty():
485+
return True
486+
487+
# apply the monkeypatch for sys.stdout.isatty()
488+
monkeypatch.setattr(pathins.stringbuilder, "IS_A_TTY", mock_isatty)
489+
res = pathins.stringbuilder.segment_total_distance(1.0, nocolor=True)
490+
assert res == "Total: 1.00 units"

0 commit comments

Comments
 (0)