Skip to content

Commit

Permalink
add segment_total_distance unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissimpkins committed Oct 9, 2020
1 parent 81dd687 commit c986e98
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_stringbuilder.py
Expand Up @@ -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"

0 comments on commit c986e98

Please sign in to comment.