summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-17 19:46:59 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-17 19:46:59 +0000
commitdc7bff2e738e5259e51bbb612ffcbae00b5505e6 (patch)
tree81a0529de1e19fb72edb6418a2cb5bfe208aa80c
parent1e786784520b5e39f60d132df3314fbef85500eb (diff)
Test writing to file from CLI
-rw-r--r--test-requirements.txt1
-rw-r--r--tests/cli_tests.py17
2 files changed, 17 insertions, 1 deletions
diff --git a/test-requirements.txt b/test-requirements.txt
index ff67a4e..2fdf3a6 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,3 +1,4 @@
nose>=1.2.1,<2.0
funk>=0.3.1,<0.4
spur.local>=0.3.7,<0.4
+tempman>=0.1.2,<0.2
diff --git a/tests/cli_tests.py b/tests/cli_tests.py
index 833cb33..4ce1d87 100644
--- a/tests/cli_tests.py
+++ b/tests/cli_tests.py
@@ -1,6 +1,8 @@
-from nose.tools import istest, assert_equal
+import os
+from nose.tools import istest, assert_equal
import spur
+import tempman
from .testing import test_path
@@ -13,3 +15,16 @@ def html_is_printed_to_stdout_if_output_file_is_not_set():
result = _local.run(["mammoth", docx_path])
assert_equal("", result.stderr_output)
assert_equal("<p>Walking on imported air</p>", result.output)
+
+
+@istest
+def html_is_written_to_file_if_output_file_is_set():
+ with tempman.create_temp_dir() as temp_dir:
+ output_path = os.path.join(temp_dir.path, "output.html")
+ docx_path = test_path("single-paragraph.docx")
+ result = _local.run(["mammoth", docx_path, output_path])
+ assert_equal("", result.stderr_output)
+ assert_equal("", result.output)
+ with open(output_path) as output_file:
+ assert_equal("<p>Walking on imported air</p>", output_file.read())
+