Beispiel #1
0
 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])
Beispiel #2
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))
Beispiel #3
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))
Beispiel #4
0
 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.")
Beispiel #5
0
 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"))
Beispiel #6
0
 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')))
Beispiel #7
0
 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'))
Beispiel #8
0
 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.")