示例#1
0
 def test_color_names_in_backgroundare_accepted(self):
     doc = LaTeXDocument(r"A = \pi r^2")
     doc.set_background_color("cyan")
     doc = str(doc)
     self.assertTrue("pagecolor{cyan}" in doc,
                     "Expected \\pagecolor in document, got: %s" % doc)
     self.assertTrue("\\color" not in doc)
     self.assertFalse("definecolor" in doc)
示例#2
0
 def test_color_names_in_backgroundare_accepted(self):
     doc = LaTeXDocument(r'A = \pi r^2')
     doc.set_background_color('cyan')
     doc = str(doc)
     self.assertTrue('pagecolor{cyan}' in doc,
                     "Expected \\pagecolor in document, got: %s" % doc)
     self.assertTrue('\\color' not in doc)
     self.assertFalse('definecolor' in doc)
示例#3
0
 def test_hex_colours_with_leading_0s_work(self):
     doc = LaTeXDocument(r'A = \pi r^2')
     doc.set_background_color('00FFCC')
     doc = str(doc)
     self.assertTrue('pagecolor{background}' in doc,
                     "Expected \\pagecolor in document, got: %s" % doc)
     self.assertTrue('definecolor' in doc)
     self.assertTrue('00FFCC' in doc)
示例#4
0
 def test_color_rgb_in_backgroundare_accepted(self):
     doc = LaTeXDocument(r'A = \pi r^2')
     doc.set_background_color('FFAACC')
     doc = str(doc)
     self.assertTrue('pagecolor{background}' in doc,
                     "Expected \\pagecolor in document, got: %s" % doc)
     self.assertTrue('\\color' not in doc)
     self.assertTrue('definecolor' in doc)
     self.assertTrue('FFAACC' in doc)
示例#5
0
 def test_color_rgb_in_foregroundare_accepted(self):
     doc = LaTeXDocument(r"A = \pi r^2")
     doc.set_foreground_color("FFAACC")
     doc = str(doc)
     self.assertTrue("pagecolor{}" not in doc,
                     "Expected \\pagecolor in document, got: %s" % doc)
     self.assertTrue("\\color{foreground" in doc,
                     "document misses \\color command: %s" % doc)
     self.assertTrue("definecolor" in doc)
     self.assertTrue("FFAACC" in doc)
示例#6
0
 def test_hex_colours_with_leading_0s_work(self):
     doc = LaTeXDocument(r"A = \pi r^2")
     doc.set_background_color("00FFCC")
     doc = str(doc)
     self.assertTrue(
         "pagecolor{background}" in doc,
         "Expected \\pagecolor in document, got: %s" % doc,
     )
     self.assertTrue("definecolor" in doc)
     self.assertTrue("00FFCC" in doc)
示例#7
0
 def test_color_rgb_in_foregroundare_accepted(self):
     doc = LaTeXDocument(r'A = \pi r^2')
     doc.set_foreground_color('FFAACC')
     doc = str(doc)
     self.assertTrue('pagecolor{}' not in doc,
                     "Expected \\pagecolor in document, got: %s" % doc)
     self.assertTrue('\\color{foreground' in doc,
                     "document misses \\color command: %s" % doc)
     self.assertTrue('definecolor' in doc)
     self.assertTrue('FFAACC' in doc)
示例#8
0
 def test_color_rgb_in_backgroundare_accepted(self):
     doc = LaTeXDocument(r"A = \pi r^2")
     doc.set_background_color("FFAACC")
     doc = str(doc)
     self.assertTrue(
         "pagecolor{background}" in doc,
         "Expected \\pagecolor in document, got: %s" % doc,
     )
     self.assertTrue("\\color" not in doc)
     self.assertTrue("definecolor" in doc)
     self.assertTrue("FFAACC" in doc)
示例#9
0
 def test_formula_is_embedded(self):
     formula = "E = m \\cdot c^2"
     doc = LaTeXDocument(formula)
     self.assertTrue(
         formula in str(doc),
         "formula must be contained in LaTeX typesetting as it was inserted.",
     )
示例#10
0
 def test_obviously_wrong_encoding_trigger_exception(self):
     doc = LaTeXDocument("f00")
     self.assertRaises(ValueError, doc.set_encoding, "latin1:")
     self.assertRaises(ValueError, doc.set_encoding, "utf66")
     # the following passes (assertRaisesNot)
     doc.set_encoding("utf-8")
示例#11
0
 def test_preamble_is_included(self):
     preamble = "\\usepackage{eurosym}"
     doc = LaTeXDocument("moooo")
     doc.set_preamble_string(preamble)
     self.assertTrue(preamble in str(doc))
示例#12
0
 def test_no_colors_no_color_definitions(self):
     doc = str(LaTeXDocument(r"A = \pi r^2"))
     self.assertFalse("pagecolor" in doc)
     self.assertFalse("\\color" in doc)
     self.assertFalse("definecolor" in doc)
示例#13
0
 def test_if_displaymath_unset_correct_env_used(self):
     doc = LaTeXDocument(r"A = \pi r^2")
     doc.set_displaymath(False)
     self.assertTrue("\\(" in str(doc))
     self.assertTrue("\\)" in str(doc))
示例#14
0
 def test_that_latex_maths_env_is_used(self):
     doc = LaTeXDocument('f00')
     doc.set_latex_environment('flalign*')
     self.assertTrue(r'\begin{flalign*}' in str(doc))
     self.assertTrue(r'\end{flalign*}' in str(doc))
示例#15
0
 def test_obviously_wrong_encoding_trigger_exception(self):
     doc = LaTeXDocument('f00')
     self.assertRaises(ValueError, doc.set_encoding, 'latin1:')
     self.assertRaises(ValueError, doc.set_encoding, 'utf66')
     # the following passes (assertRaisesNot)
     doc.set_encoding('utf-8')
示例#16
0
 def test_no_colors_no_color_definitions(self):
     doc = str(LaTeXDocument(r'A = \pi r^2'))
     self.assertFalse('pagecolor' in doc)
     self.assertFalse('\\color' in doc)
     self.assertFalse('definecolor' in doc)
示例#17
0
 def test_that_latex_maths_env_is_used(self):
     doc = LaTeXDocument("f00")
     doc.set_latex_environment("flalign*")
     self.assertTrue(r"\begin{flalign*}" in str(doc))
     self.assertTrue(r"\end{flalign*}" in str(doc))
示例#18
0
 def test_if_displaymath_is_set_correct_env_used(self):
     doc = LaTeXDocument(r"A = \pi r^2")
     doc.set_displaymath(True)
     self.assertTrue("\\[" in str(doc))
     self.assertTrue("\\]" in str(doc))
示例#19
0
 def test_if_displaymath_is_set_correct_env_used(self):
     doc = LaTeXDocument(r'A = \pi r^2')
     doc.set_displaymath(True)
     self.assertTrue('\\[' in str(doc))
     self.assertTrue('\\]' in str(doc))