def test_intermediate_files_are_removed(self): files = ["foo.tex", "foo.log", "foo.aux", "foo.dvi"] touch(files) i = image.Tex2img(Format.Png) i.convert(doc("\\hat{x}"), "foo") for intermediate_file in files: self.assertFalse(os.path.exists(intermediate_file))
def test_that_error_of_incorrect_formula_is_parsed_correctly(self): i = image.Tex2img(Format.Png) try: i.create_dvi(doc("\\foo"), "foo.png") except SubprocessError as e: # expect undefined control sequence in error output self.assertTrue("Undefined" in e.args[0])
def test_intermediate_files_are_removed(self): files = ['foo.tex', 'foo.log', 'foo.aux', 'foo.dvi'] touch(files) i = image.Tex2img(Format.Png) i.convert(doc('\\hat{x}'), 'foo') for intermediate_file in files: self.assertFalse(os.path.exists(intermediate_file))
def test_that_intermediate_files_are_removed_after_successful_run(self): files = ['foo.log', 'foo.aux', 'foo.tex'] touch(files) i = image.Tex2img(Format.Png) i.create_dvi(doc("\\frac\\pi\\tau"), 'foo.png') for intermediate_file in files: self.assertFalse( os.path.exists(intermediate_file), "File " + intermediate_file + " should not exist.")
def test_intermediate_files_are_removed_when_exception_raised(self): files = ["foo.tex", "foo.log", "foo.aux", "foo.dvi"] touch(files) i = image.Tex2img(Format.Png) try: i.convert(doc("\\hat{x}"), "foo") except SubprocessError: self.assertFalse(os.path.exists("foo.tex")) self.assertFalse(os.path.exists("foo.dvi")) self.assertFalse(os.path.exists("foo.log")) self.assertFalse(os.path.exists("foo.aux"))
def test_that_output_file_names_with_paths_are_ok_and_log_is_removed(self): fname = lambda f: os.path.join('bilder', 'farce.' + f) touch([fname('log'), fname('png')]) t = image.Tex2img(Format.Png) t.convert(doc(r"\hat{es}\pi\pi\ldots"), fname('')[:-1]) self.assertFalse(os.path.exists("farce.log")) self.assertTrue( os.path.exists(fname('png')), "couldn't find file {}, directory structure:\n{}".format( fname('png'), ''.join(pprint.pformat(list(os.walk('.')))))) self.assertFalse(os.path.exists(fname('log')))
def test_intermediate_files_are_removed_when_exception_raised(self): files = ['foo.tex', 'foo.log', 'foo.aux', 'foo.dvi'] touch(files) i = image.Tex2img(Format.Png) try: i.convert(doc('\\hat{x}'), 'foo') except SubprocessError: self.assertFalse(os.path.exists('foo.tex')) self.assertFalse(os.path.exists('foo.dvi')) self.assertFalse(os.path.exists('foo.log')) self.assertFalse(os.path.exists('foo.aux'))
def test_that_intermediate_files_are_removed_when_exception_is_raised( self): files = ['foo.log', 'foo.aux', 'foo.tex'] touch(files) # error case i = image.Tex2img(Format.Png) try: i.convert(doc("\\foo"), 'foo') except SubprocessError as e: for intermediate_file in files: self.assertFalse( os.path.exists(intermediate_file), "File " + intermediate_file + " should not exist.")
def test_that_values_for_positioning_png_are_returned(self): i = image.Tex2img(Format.Png) posdata = i.create_image("foo.dvi") self.assertTrue("height" in posdata) self.assertTrue("width" in posdata)