~ubuntu-branches/ubuntu/vivid/python-docutils/vivid

« back to all changes in this revision

Viewing changes to test/test_writers/test_html4css1_misc.py

  • Committer: Package Import Robot
  • Author(s): Dmitry Shachnev
  • Date: 2012-12-18 15:06:21 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20121218150621-htq5khi7gvpex9yp
Tags: 0.10-0ubuntu1
* New upstream stable release.
* debian/patches/disable_py33_failing_tests.diff: add DEP-3 headers.
* Merged 0.9.1-2 changes from Debian.
* Bumped Standards-Version to 3.9.4, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#! /usr/bin/env python
 
2
# coding: utf-8
2
3
 
3
 
# $Id$
4
 
# Author: Lea Wiemann
 
4
# $Id: test_html4css1_misc.py 7534 2012-10-25 11:48:32Z milde $
 
5
# Authors: Lea Wiemann, Dmitry Shachnev, Günter Milde
5
6
# Maintainer: docutils-develop@lists.sourceforge.net
6
7
# Copyright: This module has been placed in the public domain.
7
8
 
13
14
from docutils import core
14
15
from docutils._compat import b
15
16
 
16
 
 
17
17
class EncodingTestCase(DocutilsTestSupport.StandardTestCase):
18
18
 
19
19
    def test_xmlcharrefreplace(self):
28
28
            settings_overrides=settings_overrides)
29
29
        # Encoding a euro sign with latin1 doesn't work, so the
30
30
        # xmlcharrefreplace handler is used.
31
 
        self.assertNotEqual(result.find(b('EUR = €')), -1)
 
31
        self.assertIn(b('EUR = €'), result)
 
32
 
 
33
class MathTestCase(DocutilsTestSupport.StandardTestCase):
 
34
    
 
35
    """Attention: This class tests the current implementation of maths support
 
36
    which is open to change in future Docutils releases. """
 
37
 
 
38
    settings_overrides={'_disable_config': True,}
 
39
    mathjax_script = '<script type="text/javascript" src="%s">'
 
40
    default_mathjax_url = ('http://cdn.mathjax.org/mathjax/latest/MathJax.js'
 
41
                           '?config=TeX-AMS-MML_HTMLorMML')
 
42
    custom_mathjax_url = ('file:///usr/share/javascript/mathjax/MathJax.js'
 
43
                          '?config=TeX-AMS-MML_HTMLorMML')
 
44
    data = ':math:`42`'
 
45
 
 
46
    def test_math_output_default(self):
 
47
        # Currently MathJax with default URL. Likely to change to HTML!
 
48
        mysettings = self.settings_overrides
 
49
        head = core.publish_parts(self.data, writer_name='html4css1',
 
50
                                  settings_overrides=mysettings)['head']
 
51
        self.assertIn(self.mathjax_script % self.default_mathjax_url, head)
 
52
        
 
53
    def test_math_output_mathjax(self):
 
54
        # Explicitly specifying math_output=MathJax, case insensitively
 
55
        # use default MathJax URL
 
56
        mysettings = self.settings_overrides.copy()
 
57
        mysettings.update({'math_output': 'MathJax'})
 
58
        head = core.publish_parts(self.data, writer_name='html4css1',
 
59
            settings_overrides=mysettings)['head']
 
60
        self.assertIn(self.mathjax_script % self.default_mathjax_url, head)
 
61
 
 
62
    def test_math_output_mathjax_custom(self):
 
63
        # Customizing MathJax URL
 
64
        mysettings = self.settings_overrides.copy()
 
65
        mysettings.update({'math_output': 
 
66
                           'mathjax %s' % self.custom_mathjax_url})
 
67
        head = core.publish_parts(self.data, writer_name='html4css1',
 
68
            settings_overrides=mysettings)['head']
 
69
        self.assertIn(self.mathjax_script % self.custom_mathjax_url, head)
 
70
        
 
71
    def test_math_output_html(self):
 
72
        # There should be no MathJax script when math_output is not MathJax
 
73
        mysettings = self.settings_overrides.copy()
 
74
        mysettings.update({'math_output': 'HTML'})
 
75
        head = core.publish_parts(self.data, writer_name='html4css1',
 
76
            settings_overrides=mysettings)['head']
 
77
        self.assertNotIn('MathJax.js', head)
 
78
        
 
79
    def test_math_output_mathjax_no_math(self):
 
80
        mysettings = self.settings_overrides.copy()
 
81
        mysettings.update({'math_output': 'MathJax'})
 
82
        # There should be no math script when text does not contain math
 
83
        head = core.publish_parts('No math.', writer_name='html4css1')['head']
 
84
        self.assertNotIn('MathJax', head)
32
85
 
33
86
 
34
87
if __name__ == '__main__':