Skip to content

Commit

Permalink
Simplify testing for color or no-color
Browse files Browse the repository at this point in the history
  • Loading branch information
oz123 authored and Oz N Tiram committed Nov 4, 2017
1 parent 9cf8db4 commit bf5933d
Showing 1 changed file with 2 additions and 22 deletions.
24 changes: 2 additions & 22 deletions tests/functional/test_no_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,7 @@ def test_no_color(script):
stdout=sp.PIPE, stderr=sp.PIPE).communicate()

with open("/tmp/colored-output.txt", "r") as result:

red_lines = 0
reset_lines = 0

for line in result.readlines():
if line.startswith("\x1b[31m"):
red_lines += 1
if line.endswith("\x1b[0m\n"):
reset_lines += 1

assert red_lines >= 1
assert reset_lines >= 1
assert "\x1b[31m" in result.read()

os.unlink("/tmp/colored-output.txt")

Expand All @@ -47,15 +36,6 @@ def test_no_color(script):
stdout=sp.PIPE, stderr=sp.PIPE).communicate()

with open("/tmp/no-color-output.txt", "r") as result:
red_lines = 0
reset_lines = 0
for line in result.readlines():
if line.startswith("\x1b[31m"):
red_lines += 1
if line.endswith("\x1b[0m\n"):
reset_lines += 1
assert "\x1b[31m" not in result.read()

os.unlink("/tmp/no-color-output.txt")

assert red_lines == 0
assert reset_lines == 0

0 comments on commit bf5933d

Please sign in to comment.