Skip to content

Commit 367f1a3

Browse files
committed
add markdown mode test
1 parent 0f3cc3e commit 367f1a3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_tldr.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ def test_whole_page():
2323
correct_output = f_rendered.read()
2424
assert tldr_output == correct_output
2525

26+
def test_markdown_mode():
27+
with open("tests/data/gem.md", "rb") as f_original:
28+
d_original = f_original.read()
29+
old_stdout = sys.stdout
30+
sys.stdout = io.StringIO()
31+
sys.stdout.buffer = types.SimpleNamespace()
32+
sys.stdout.buffer.write = lambda x: sys.stdout.write(x.decode("utf-8"))
33+
tldr.output(d_original.splitlines(), plain=True)
34+
35+
sys.stdout.seek(0)
36+
tldr_output = sys.stdout.read().encode("utf-8")
37+
sys.stdout = old_stdout
38+
39+
assert tldr_output == d_original
2640

2741
def test_error_message():
2842
with mock.patch("sys.argv", ["tldr", "73eb6f19cd6f"]):

0 commit comments

Comments
 (0)