From 5bb0bb4be543fd5eca41673696a62ed80d493591 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 5 Jun 2024 18:20:58 +0200 Subject: Adding upstream version 7.3.7. Signed-off-by: Daniel Baumann --- tests/test_markup/test_smartquotes.py | 98 +++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 tests/test_markup/test_smartquotes.py (limited to 'tests/test_markup/test_smartquotes.py') diff --git a/tests/test_markup/test_smartquotes.py b/tests/test_markup/test_smartquotes.py new file mode 100644 index 0000000..6c84386 --- /dev/null +++ b/tests/test_markup/test_smartquotes.py @@ -0,0 +1,98 @@ +"""Test smart quotes.""" + +import pytest + +from sphinx.testing.util import etree_parse + + +@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True) +def test_basic(app, status, warning): + app.build() + + content = (app.outdir / 'index.html').read_text(encoding='utf8') + assert '

– “Sphinx” is a tool that makes it easy …

' in content + + +@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True) +def test_literals(app, status, warning): + app.build() + + etree = etree_parse(app.outdir / 'literals.html') + for code_element in etree.iter('code'): + code_text = ''.join(code_element.itertext()) + + if code_text.startswith('code role'): + assert "'quotes'" in code_text + elif code_text.startswith('{'): + assert code_text == "{'code': 'role', 'with': 'quotes'}" + elif code_text.startswith('literal'): + assert code_text == "literal with 'quotes'" + + +@pytest.mark.sphinx(buildername='text', testroot='smartquotes', freshenv=True) +def test_text_builder(app, status, warning): + app.build() + + content = (app.outdir / 'index.txt').read_text(encoding='utf8') + assert '-- "Sphinx" is a tool that makes it easy ...' in content + + +@pytest.mark.sphinx(buildername='man', testroot='smartquotes', freshenv=True) +def test_man_builder(app, status, warning): + app.build() + + content = (app.outdir / 'python.1').read_text(encoding='utf8') + assert r'\-\- \(dqSphinx\(dq is a tool that makes it easy ...' in content + + +@pytest.mark.sphinx(buildername='latex', testroot='smartquotes', freshenv=True) +def test_latex_builder(app, status, warning): + app.build() + + content = (app.outdir / 'python.tex').read_text(encoding='utf8') + assert '\\textendash{} “Sphinx” is a tool that makes it easy …' in content + + +@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True, + confoverrides={'language': 'ja'}) +def test_ja_html_builder(app, status, warning): + app.build() + + content = (app.outdir / 'index.html').read_text(encoding='utf8') + assert '

-- "Sphinx" is a tool that makes it easy ...

' in content + + +@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True, + confoverrides={'smartquotes': False}) +def test_smartquotes_disabled(app, status, warning): + app.build() + + content = (app.outdir / 'index.html').read_text(encoding='utf8') + assert '

-- "Sphinx" is a tool that makes it easy ...

' in content + + +@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True, + confoverrides={'smartquotes_action': 'q'}) +def test_smartquotes_action(app, status, warning): + app.build() + + content = (app.outdir / 'index.html').read_text(encoding='utf8') + assert '

-- “Sphinx” is a tool that makes it easy ...

' in content + + +@pytest.mark.sphinx(buildername='html', testroot='smartquotes', freshenv=True, + confoverrides={'language': 'ja', 'smartquotes_excludes': {}}) +def test_smartquotes_excludes_language(app, status, warning): + app.build() + + content = (app.outdir / 'index.html').read_text(encoding='utf8') + assert '

– 「Sphinx」 is a tool that makes it easy …

' in content + + +@pytest.mark.sphinx(buildername='man', testroot='smartquotes', freshenv=True, + confoverrides={'smartquotes_excludes': {}}) +def test_smartquotes_excludes_builders(app, status, warning): + app.build() + + content = (app.outdir / 'python.1').read_text(encoding='utf8') + assert '– “Sphinx” is a tool that makes it easy …' in content -- cgit v1.2.3