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)
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)
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)
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)
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)
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)
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)
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)
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.", )
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")
def test_preamble_is_included(self): preamble = "\\usepackage{eurosym}" doc = LaTeXDocument("moooo") doc.set_preamble_string(preamble) self.assertTrue(preamble in str(doc))
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)
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))
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))
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')
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)
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))
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))
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))