mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge branch 'stable'
This commit is contained in:
@@ -62,3 +62,7 @@ Test for issue #1700
|
||||
|
||||
:ref:`mastertoc`
|
||||
|
||||
Test for indirect hyperlink targets
|
||||
===================================
|
||||
|
||||
:ref:`indirect hyperref <other-label>`
|
||||
|
||||
@@ -107,6 +107,9 @@ Admonitions
|
||||
.. tip::
|
||||
Tip text.
|
||||
|
||||
Indirect hyperlink targets
|
||||
|
||||
.. _other-label: some-label_
|
||||
|
||||
Inline markup
|
||||
-------------
|
||||
@@ -142,6 +145,7 @@ Adding \n to test unescaping.
|
||||
* :token:`try statement <try_stmt>`
|
||||
* :ref:`admonition-section`
|
||||
* :ref:`here <some-label>`
|
||||
* :ref:`there <other-label>`
|
||||
* :ref:`my-figure`
|
||||
* :ref:`my-figure-name`
|
||||
* :ref:`my-table`
|
||||
@@ -231,6 +235,16 @@ Figures
|
||||
|
||||
Description paragraph is wraped with legend node.
|
||||
|
||||
.. figure:: rimg.png
|
||||
:align: right
|
||||
|
||||
figure with align option
|
||||
|
||||
.. figure:: rimg.png
|
||||
:align: right
|
||||
:figwidth: 50%
|
||||
|
||||
figure with align & figwidth option
|
||||
|
||||
Version markup
|
||||
--------------
|
||||
|
||||
3
tests/roots/test-correct-year/conf.py
Normal file
3
tests/roots/test-correct-year/conf.py
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
copyright = u'2006-2009, Author'
|
||||
|
||||
4
tests/roots/test-correct-year/contents.rst
Normal file
4
tests/roots/test-correct-year/contents.rst
Normal file
@@ -0,0 +1,4 @@
|
||||
=================
|
||||
test-correct-year
|
||||
=================
|
||||
|
||||
@@ -16,3 +16,7 @@ another blah
|
||||
Other [blah] |picture| section
|
||||
------------------------------
|
||||
other blah
|
||||
|
||||
|picture|
|
||||
---------
|
||||
blah blah blah
|
||||
|
||||
@@ -31,16 +31,16 @@ http://www.python.org/logo.png
|
||||
reading included file u'.*?wrongenc.inc' seems to be wrong, try giving an \
|
||||
:encoding: option\\n?
|
||||
%(root)s/includes.txt:4: WARNING: download file not readable: .*?nonexisting.png
|
||||
(%(root)s/markup.txt:359: WARNING: invalid single index entry u'')?
|
||||
(%(root)s/markup.txt:373: WARNING: invalid single index entry u'')?
|
||||
(%(root)s/undecodable.txt:3: WARNING: undecodable source characters, replacing \
|
||||
with "\\?": b?'here: >>>(\\\\|/)xbb<<<'
|
||||
)?"""
|
||||
|
||||
HTML_WARNINGS = ENV_WARNINGS + """\
|
||||
%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*'
|
||||
%(root)s/markup.txt:271: WARNING: Could not lex literal_block as "c". Highlighting skipped.
|
||||
%(root)s/markup.txt:285: WARNING: Could not lex literal_block as "c". Highlighting skipped.
|
||||
%(root)s/footnote.txt:60: WARNING: citation not found: missing
|
||||
%(root)s/markup.txt:160: WARNING: unknown option: &option
|
||||
%(root)s/markup.txt:164: WARNING: unknown option: &option
|
||||
"""
|
||||
|
||||
if PY3:
|
||||
@@ -151,6 +151,8 @@ HTML_XPATH = {
|
||||
"[@class='reference internal']/code/span[@class='pre']", '^with$'),
|
||||
(".//a[@href='#grammar-token-try_stmt']"
|
||||
"[@class='reference internal']/code/span", '^statement$'),
|
||||
(".//a[@href='#some-label'][@class='reference internal']/span", '^here$'),
|
||||
(".//a[@href='#some-label'][@class='reference internal']/span", '^there$'),
|
||||
(".//a[@href='subdir/includes.html']"
|
||||
"[@class='reference internal']/span", 'Including in subdir'),
|
||||
(".//a[@href='objects.html#cmdoption-python-c']"
|
||||
@@ -274,6 +276,9 @@ HTML_XPATH = {
|
||||
'http://sphinx-doc.org/'),
|
||||
(".//a[@class='reference external'][@href='http://sphinx-doc.org/latest/']",
|
||||
'Latest reference'),
|
||||
# Indirect hyperlink targets across files
|
||||
(".//a[@href='markup.html#some-label'][@class='reference internal']/span",
|
||||
'^indirect hyperref$'),
|
||||
],
|
||||
'bom.html': [
|
||||
(".//title", " File with UTF-8 BOM"),
|
||||
|
||||
@@ -24,10 +24,10 @@ from test_build_html import ENV_WARNINGS
|
||||
|
||||
|
||||
LATEX_WARNINGS = ENV_WARNINGS + """\
|
||||
%(root)s/markup.txt:160: WARNING: unknown option: &option
|
||||
%(root)s/markup.txt:164: WARNING: unknown option: &option
|
||||
%(root)s/footnote.txt:60: WARNING: citation not found: missing
|
||||
%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*'
|
||||
%(root)s/markup.txt:271: WARNING: Could not lex literal_block as "c". Highlighting skipped.
|
||||
%(root)s/markup.txt:285: WARNING: Could not lex literal_block as "c". Highlighting skipped.
|
||||
"""
|
||||
|
||||
if PY3:
|
||||
@@ -106,6 +106,20 @@ def test_latex(app, status, warning):
|
||||
run_latex(app.outdir)
|
||||
|
||||
|
||||
@with_app(buildername='latex')
|
||||
def test_writer(app, status, warning):
|
||||
app.builder.build_all()
|
||||
result = (app.outdir / 'SphinxTests.tex').text(encoding='utf8')
|
||||
|
||||
assert ('\\begin{wrapfigure}{r}{0pt}\n\\centering\n'
|
||||
'\\includegraphics{{rimg}.png}\n\\caption{figure with align option}'
|
||||
'\\label{markup:id7}\\end{wrapfigure}' in result)
|
||||
|
||||
assert ('\\begin{wrapfigure}{r}{0.500\\linewidth}\n\\centering\n'
|
||||
'\\includegraphics{{rimg}.png}\n\\caption{figure with align \\& figwidth option}'
|
||||
'\\label{markup:id8}\\end{wrapfigure}' in result)
|
||||
|
||||
|
||||
@with_app(buildername='latex', freshenv=True, # use freshenv to check warnings
|
||||
confoverrides={'latex_documents': [
|
||||
('contents', 'SphinxTests.tex', 'Sphinx Tests Documentation',
|
||||
|
||||
@@ -23,7 +23,7 @@ from test_build_html import ENV_WARNINGS
|
||||
|
||||
|
||||
TEXINFO_WARNINGS = ENV_WARNINGS + """\
|
||||
%(root)s/markup.txt:160: WARNING: unknown option: &option
|
||||
%(root)s/markup.txt:164: WARNING: unknown option: &option
|
||||
%(root)s/footnote.txt:60: WARNING: citation not found: missing
|
||||
%(root)s/images.txt:20: WARNING: no matching candidate for image URI u'foo.\\*'
|
||||
%(root)s/images.txt:29: WARNING: no matching candidate for image URI u'svgimg.\\*'
|
||||
|
||||
49
tests/test_correct_year.py
Normal file
49
tests/test_correct_year.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
test_correct_year
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test copyright year adjustment
|
||||
|
||||
:copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
|
||||
:license: BSD, see LICENSE for details.
|
||||
"""
|
||||
import os
|
||||
|
||||
from util import TestApp
|
||||
|
||||
|
||||
def test_correct_year():
|
||||
try:
|
||||
# save current value of SOURCE_DATE_EPOCH
|
||||
sde = os.environ.pop('SOURCE_DATE_EPOCH',None)
|
||||
|
||||
# test with SOURCE_DATE_EPOCH unset: no modification
|
||||
app = TestApp(buildername='html',testroot='correct-year')
|
||||
app.builder.build_all()
|
||||
content = (app.outdir / 'contents.html').text()
|
||||
app.cleanup()
|
||||
assert '2006-2009' in content
|
||||
|
||||
# test with SOURCE_DATE_EPOCH set: copyright year should be
|
||||
# updated
|
||||
os.environ['SOURCE_DATE_EPOCH'] = "1293840000"
|
||||
app = TestApp(buildername='html',testroot='correct-year')
|
||||
app.builder.build_all()
|
||||
content = (app.outdir / 'contents.html').text()
|
||||
app.cleanup()
|
||||
assert '2006-2011' in content
|
||||
|
||||
os.environ['SOURCE_DATE_EPOCH'] = "1293839999"
|
||||
app = TestApp(buildername='html',testroot='correct-year')
|
||||
app.builder.build_all()
|
||||
content = (app.outdir / 'contents.html').text()
|
||||
app.cleanup()
|
||||
assert '2006-2010' in content
|
||||
|
||||
finally:
|
||||
# Restores SOURCE_DATE_EPOCH
|
||||
if sde == None:
|
||||
os.environ.pop('SOURCE_DATE_EPOCH',None)
|
||||
else:
|
||||
os.environ['SOURCE_DATE_EPOCH'] = sde
|
||||
@@ -24,7 +24,7 @@ def setup_module():
|
||||
global app, env
|
||||
app = TestApp(srcdir='root-envtest')
|
||||
env = app.env
|
||||
env.set_warnfunc(lambda *args: warnings.append(args))
|
||||
env.set_warnfunc(lambda *args, **kwargs: warnings.append(args))
|
||||
|
||||
|
||||
def teardown_module():
|
||||
|
||||
@@ -199,6 +199,16 @@ class TestStripBasicAuth(unittest.TestCase):
|
||||
self.assertEqual(None, actual_username)
|
||||
self.assertEqual(None, actual_password)
|
||||
|
||||
def test_having_port(self):
|
||||
"""basic auth creds correctly stripped from URL containing creds even if URL
|
||||
contains port"""
|
||||
url = 'https://user:12345@domain.com:8080/project/objects.inv'
|
||||
expected = 'https://domain.com:8080/project/objects.inv'
|
||||
actual_url, actual_username, actual_password = _strip_basic_auth(url)
|
||||
self.assertEqual(expected, actual_url)
|
||||
self.assertEqual('user', actual_username)
|
||||
self.assertEqual('12345', actual_password)
|
||||
|
||||
|
||||
@mock.patch('six.moves.urllib.request.HTTPBasicAuthHandler')
|
||||
@mock.patch('six.moves.urllib.request.HTTPPasswordMgrWithDefaultRealm')
|
||||
|
||||
Reference in New Issue
Block a user