summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakayuki Shimizukawa <shimizukawa@gmail.com>2014-08-10 22:23:52 +0900
committerTakayuki Shimizukawa <shimizukawa@gmail.com>2014-08-10 22:23:52 +0900
commited9de1c9e8cba940a721bad5455457894f4f2c97 (patch)
tree58f9c6a280eaf0c3dce2c5239fee1dd6d2aef0f1
parent14353b30c20ca5d34bbfade4d0b71330d377e870 (diff)
downloadsphinx-git-ed9de1c9e8cba940a721bad5455457894f4f2c97.tar.gz
* provide _copy_to_temp option for TestApp()
-rwxr-xr-xtests/path.py3
-rw-r--r--tests/test_build.py2
-rw-r--r--tests/test_env.py2
-rw-r--r--tests/test_linkcode.py2
-rw-r--r--tests/test_metadata.py2
-rw-r--r--tests/util.py18
6 files changed, 18 insertions, 11 deletions
diff --git a/tests/path.py b/tests/path.py
index 2a4affe77..3e2c8f89e 100755
--- a/tests/path.py
+++ b/tests/path.py
@@ -36,6 +36,9 @@ class path(text_type):
"""
return self.__class__(os.path.dirname(self))
+ def basename(self):
+ return os.path.basename(self)
+
def abspath(self):
"""
Returns the absolute path.
diff --git a/tests/test_build.py b/tests/test_build.py
index c355b1622..c8001271e 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -76,6 +76,6 @@ def test_nonascii_path():
builder_names.append('man')
for buildername in builder_names:
- app = TestApp(buildername=buildername, srcdir='(temp)')
+ app = TestApp(buildername=buildername, _copy_to_temp=True)
yield _test_nonascii_path, app
app.cleanup()
diff --git a/tests/test_env.py b/tests/test_env.py
index 443f249c7..3dc7431b9 100644
--- a/tests/test_env.py
+++ b/tests/test_env.py
@@ -20,7 +20,7 @@ warnings = []
def setup_module():
global app, env
- app = TestApp(srcdir='(temp)', freshenv=True)
+ app = TestApp(freshenv=True, _copy_to_temp=True)
env = app.env
env.set_warnfunc(lambda *args: warnings.append(args))
diff --git a/tests/test_linkcode.py b/tests/test_linkcode.py
index 83b720984..458477781 100644
--- a/tests/test_linkcode.py
+++ b/tests/test_linkcode.py
@@ -13,7 +13,7 @@ import os
from util import with_app
-@with_app(srcdir='(temp)', buildername='html', tags=['test_linkcode'])
+@with_app(buildername='html', tags=['test_linkcode'], _copy_to_temp=True)
def test_html(app):
app.builder.build_all()
diff --git a/tests/test_metadata.py b/tests/test_metadata.py
index 12a99a5d6..a3fd13587 100644
--- a/tests/test_metadata.py
+++ b/tests/test_metadata.py
@@ -23,7 +23,7 @@ warnings = []
def setup_module():
# Is there a better way of generating this doctree than manually iterating?
global app, env
- app = TestApp(srcdir='(temp)')
+ app = TestApp(_copy_to_temp=True)
env = app.env
msg, num, it = env.update(app.config, app.srcdir, app.doctreedir, app)
for docname in it:
diff --git a/tests/util.py b/tests/util.py
index acb4b8573..1b5719b5f 100644
--- a/tests/util.py
+++ b/tests/util.py
@@ -130,7 +130,9 @@ class TestApp(application.Sphinx):
buildername='html', confoverrides=None,
status=None, warning=None, freshenv=None,
warningiserror=None, tags=None,
- confname='conf.py', cleanenv=False):
+ confname='conf.py', cleanenv=False,
+ _copy_to_temp=False,
+ ):
application.CONFIG_FILENAME = confname
@@ -138,12 +140,6 @@ class TestApp(application.Sphinx):
if srcdir is None:
srcdir = test_root
- if srcdir == '(temp)':
- tempdir = path(tempfile.mkdtemp())
- self.cleanup_trees.append(tempdir)
- temproot = tempdir / 'root'
- test_root.copytree(temproot)
- srcdir = temproot
elif srcdir == '(empty)':
tempdir = path(tempfile.mkdtemp())
self.cleanup_trees.append(tempdir)
@@ -153,6 +149,14 @@ class TestApp(application.Sphinx):
srcdir = temproot
else:
srcdir = path(srcdir)
+
+ if _copy_to_temp:
+ tempdir = path(tempfile.mkdtemp())
+ self.cleanup_trees.append(tempdir)
+ temproot = tempdir / srcdir.basename()
+ srcdir.copytree(temproot)
+ srcdir = temproot
+
self.builddir = srcdir.joinpath('_build')
if confdir is None:
confdir = srcdir