aboutsummaryrefslogtreecommitdiff
path: root/tests/docx/files_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/docx/files_tests.py')
-rw-r--r--tests/docx/files_tests.py25
1 files changed, 9 insertions, 16 deletions
diff --git a/tests/docx/files_tests.py b/tests/docx/files_tests.py
index f6c0120..6845cc2 100644
--- a/tests/docx/files_tests.py
+++ b/tests/docx/files_tests.py
@@ -1,12 +1,9 @@
-from nose.tools import istest, assert_equal
-
from mammoth.docx.files import Files, InvalidFileReferenceError
-from ..testing import test_path, assert_raises
+from ..testing import generate_test_path, assert_equal, assert_raises
-@istest
-def can_open_files_with_file_uri():
- path = test_path("tiny-picture.png")
+def test_can_open_files_with_file_uri():
+ path = generate_test_path("tiny-picture.png")
files = Files(None)
with files.open("file:///" + path) as image_file:
contents = image_file.read()
@@ -15,18 +12,16 @@ def can_open_files_with_file_uri():
assert_equal(source_file.read(), contents)
-@istest
-def can_open_files_with_relative_uri():
- files = Files(test_path(""))
+def test_can_open_files_with_relative_uri():
+ files = Files(generate_test_path(""))
with files.open("tiny-picture.png") as image_file:
contents = image_file.read()
assert_equal(bytes, type(contents))
- with open(test_path("tiny-picture.png"), "rb") as source_file:
+ with open(generate_test_path("tiny-picture.png"), "rb") as source_file:
assert_equal(source_file.read(), contents)
-@istest
-def given_base_is_not_set_when_opening_relative_uri_then_error_is_raised():
+def test_given_base_is_not_set_when_opening_relative_uri_then_error_is_raised():
files = Files(None)
error = assert_raises(InvalidFileReferenceError, lambda: files.open("not-a-real-file.png"))
expected_message = (
@@ -35,8 +30,7 @@ def given_base_is_not_set_when_opening_relative_uri_then_error_is_raised():
assert_equal(expected_message, str(error))
-@istest
-def error_is_raised_if_relative_uri_cannot_be_opened():
+def test_error_is_raised_if_relative_uri_cannot_be_opened():
files = Files("/tmp")
error = assert_raises(InvalidFileReferenceError, lambda: files.open("not-a-real-file.png"))
expected_message = (
@@ -46,8 +40,7 @@ def error_is_raised_if_relative_uri_cannot_be_opened():
assert_equal(expected_message, str(error))
-@istest
-def error_is_raised_if_file_uri_cannot_be_opened():
+def test_error_is_raised_if_file_uri_cannot_be_opened():
files = Files("/tmp")
error = assert_raises(InvalidFileReferenceError, lambda: files.open("file:///not-a-real-file.png"))
expected_message = "could not open external image: 'file:///not-a-real-file.png' (document directory: '/tmp')\n"