summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2013-09-18 08:51:20 +0000
committershimizukawa <shimizukawa@gmail.com>2013-09-18 08:51:20 +0000
commit9e10b11371a0db98e9b571cf57f463b230c04347 (patch)
tree4f255d1a7f9d2d7fe69a6fbd466fbe9e8f5066d2 /tests
parentf06769258d2044eaf15e9c8030a29f4759c724f2 (diff)
downloadsphinx-9e10b11371a0db98e9b571cf57f463b230c04347.tar.gz
Fix again: NFC/NFD normalizing problem. Closes #1142
Diffstat (limited to 'tests')
-rw-r--r--tests/roots/test-setup/doc/conf.py5
-rw-r--r--tests/roots/test-setup/doc/contents.txt5
-rw-r--r--tests/roots/test-setup/setup.cfg5
-rw-r--r--tests/roots/test-setup/setup.py9
-rw-r--r--tests/test_setup_command.py82
5 files changed, 106 insertions, 0 deletions
diff --git a/tests/roots/test-setup/doc/conf.py b/tests/roots/test-setup/doc/conf.py
new file mode 100644
index 00000000..a55679a4
--- /dev/null
+++ b/tests/roots/test-setup/doc/conf.py
@@ -0,0 +1,5 @@
+# -*- coding: utf-8 -*-
+
+project = 'Sphinx smallest project'
+source_suffix = '.txt'
+keep_warnings = True
diff --git a/tests/roots/test-setup/doc/contents.txt b/tests/roots/test-setup/doc/contents.txt
new file mode 100644
index 00000000..cb52405f
--- /dev/null
+++ b/tests/roots/test-setup/doc/contents.txt
@@ -0,0 +1,5 @@
+contents
+=========
+
+spam egg ham
+
diff --git a/tests/roots/test-setup/setup.cfg b/tests/roots/test-setup/setup.cfg
new file mode 100644
index 00000000..cf2a7f56
--- /dev/null
+++ b/tests/roots/test-setup/setup.cfg
@@ -0,0 +1,5 @@
+[build_sphinx]
+project = 'My project'
+version = 1.2
+release = 1.2.0
+source-dir = doc
diff --git a/tests/roots/test-setup/setup.py b/tests/roots/test-setup/setup.py
new file mode 100644
index 00000000..3ba5b6f0
--- /dev/null
+++ b/tests/roots/test-setup/setup.py
@@ -0,0 +1,9 @@
+from distutils.core import setup
+from sphinx.setup_command import BuildDoc
+
+cmdclass = {'build_sphinx': BuildDoc}
+
+setup(
+ name='sphinxdoc',
+ cmdclass=cmdclass,
+)
diff --git a/tests/test_setup_command.py b/tests/test_setup_command.py
new file mode 100644
index 00000000..23b2b4b7
--- /dev/null
+++ b/tests/test_setup_command.py
@@ -0,0 +1,82 @@
+# -*- coding: utf-8 -*-
+"""
+ test_setup_command
+ ~~~~~~~~~~~~~~~~~~~
+
+ Test setup_command for distutils.
+
+ :copyright: Copyright 2007-2013 by the Sphinx team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import os
+import sys
+import subprocess
+from functools import wraps
+import tempfile
+
+from util import with_tempdir, test_roots
+from path import path
+from textwrap import dedent
+
+root = test_roots / 'test-setup'
+
+
+def with_setup_command(root, *args, **kwds):
+ """
+ Run `setup.py build_sphinx` with args and kwargs,
+ pass it to the test and clean up properly.
+ """
+ def generator(func):
+ @wraps(func)
+ def deco(*args2, **kwargs2):
+ tempdir = path(tempfile.mkdtemp())
+ pkgrootdir = (tempdir / 'root')
+ root.copytree(pkgrootdir)
+ cwd = os.getcwd()
+ os.chdir(pkgrootdir)
+ command = [sys.executable, 'setup.py', 'build_sphinx']
+ command.extend(args)
+ try:
+ proc = subprocess.Popen(
+ command,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ func(pkgrootdir, proc, *args, **kwds)
+ finally:
+ tempdir.rmtree()
+ os.chdir(cwd)
+ return deco
+ return generator
+
+
+@with_setup_command(root)
+def test_build_sphinx(pkgroot, proc):
+ out, err = proc.communicate()
+ print(out)
+ print(err)
+ assert proc.returncode == 0
+
+
+@with_setup_command(root)
+def test_build_sphinx_with_multibyte_path(pkgroot, proc):
+ mb_name = u'\u65e5\u672c\u8a9e'
+ srcdir = (pkgroot / 'doc')
+ (srcdir / mb_name).makedirs()
+ (srcdir / mb_name / (mb_name + '.txt')).write_text(dedent("""
+ multi byte file name page
+ ==========================
+ """))
+
+ master_doc = srcdir / 'contents.txt'
+ master_doc.write_bytes((master_doc.text() + dedent("""
+ .. toctree::
+
+ %(mb_name)s/%(mb_name)s
+ """ % locals())
+ ).encode('utf-8'))
+
+ out, err = proc.communicate()
+ print(out)
+ print(err)
+ assert proc.returncode == 0