From c986e98dad8239a3998a59e00f82c8c6888ccd60 Mon Sep 17 00:00:00 2001 From: Chris Simpkins Date: Thu, 8 Oct 2020 23:50:03 -0400 Subject: [PATCH] add segment_total_distance unit tests --- tests/test_stringbuilder.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/test_stringbuilder.py b/tests/test_stringbuilder.py index 80d098a..9644dff 100644 --- a/tests/test_stringbuilder.py +++ b/tests/test_stringbuilder.py @@ -466,3 +466,25 @@ def mock_isatty(): coord1, coord2, coord3, 1.0, nocolor=True ) assert res == "(0,0) (1,1) (2,2): QCURVE 1.00 units" + + +def test_segment_total_distance_default(monkeypatch): + # mock tty + def mock_isatty(): + return True + + # apply the monkeypatch for sys.stdout.isatty() + monkeypatch.setattr(pathins.stringbuilder, "IS_A_TTY", mock_isatty) + res = pathins.stringbuilder.segment_total_distance(1.0) + assert res == "\033[1mTotal\033[0m: 1.00 units" + + +def test_segment_total_distance_nocolor(monkeypatch): + # mock tty + def mock_isatty(): + return True + + # apply the monkeypatch for sys.stdout.isatty() + monkeypatch.setattr(pathins.stringbuilder, "IS_A_TTY", mock_isatty) + res = pathins.stringbuilder.segment_total_distance(1.0, nocolor=True) + assert res == "Total: 1.00 units"