def test_convert_to_html_status_code(self): with NamedTemporaryFile() as f: result = main([ '--html', 'tests/fixtures/inline_tags.docx', f.name, ]) self.assertEqual(result, 0)
def test_convert_to_html_result(self): fixture_html = open("tests/fixtures/inline_tags.html").read() expected_html = BASE_HTML % fixture_html with NamedTemporaryFile() as f: result = main(["--html", "tests/fixtures/inline_tags.docx", f.name]) data = open(f.name).read() assert_html_equal(data, expected_html) self.assertEqual(result, 0)
def test_file_handles_to_docx_are_released(self): # Copy the docx to another location so we can open it, and delete it with NamedTemporaryFile(delete=False) as input_docx: copyfile('tests/fixtures/inline_tags.docx', input_docx.name) with NamedTemporaryFile() as output: result = main(['--html', input_docx.name, output.name]) self.assertEqual(result, 0) unlink(input_docx.name) input_docx.close()
def test_convert_to_html_result(self): fixture_html = open('tests/fixtures/inline_tags.html').read() expected_html = BASE_HTML % fixture_html with NamedTemporaryFile() as f: result = main([ '--html', 'tests/fixtures/inline_tags.docx', f.name, ]) data = open(f.name).read() assert_html_equal(data, expected_html) self.assertEqual(result, 0)
def test_return_code_with_three_args(self): result = main(['foo', 'bar', 'baz']) self.assertEqual(result, 2)
def test_return_code_with_one_args(self): result = main(['foo']) self.assertEqual(result, 1)
def test_return_code_with_no_args(self): result = main() self.assertEqual(result, 1)
def test_return_code_with_three_args(self): result = main(["foo", "bar", "baz"]) self.assertEqual(result, 2)