diff options
| author | Georg Brandl <georg@python.org> | 2012-10-28 18:01:57 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2012-10-28 18:01:57 +0100 |
| commit | 37fb2785f646d91ab4300b9e1791083160b700b2 (patch) | |
| tree | e043f82e1c3aa26f5283bd582b7176a5d3b77460 /tests | |
| parent | 0f043f68a08f0a93da6dc4c07b215a5ae7b8680d (diff) | |
| parent | c8258288b45ad20b8dde3a932cf874a11244219b (diff) | |
| download | sphinx-37fb2785f646d91ab4300b9e1791083160b700b2.tar.gz | |
merge with stable
Diffstat (limited to 'tests')
| -rwxr-xr-x | tests/run.py | 15 | ||||
| -rw-r--r-- | tests/test_application.py | 21 |
2 files changed, 31 insertions, 5 deletions
diff --git a/tests/run.py b/tests/run.py index ee63fa3f..8b3bf844 100755 --- a/tests/run.py +++ b/tests/run.py @@ -11,19 +11,24 @@ """ import sys -from os import path, chdir, listdir +from os import path, chdir, listdir, environ if sys.version_info >= (3, 0): print('Copying and converting sources to build/lib/tests...') from distutils.util import copydir_run_2to3 testroot = path.dirname(__file__) or '.' - newroot = path.join(testroot, path.pardir, 'build') - newroot = path.join(newroot, listdir(newroot)[0], 'tests') + if 'BUILD_TEST_PATH' in environ: + # for tox test. + newroot = environ['BUILD_TEST_PATH'] + # tox install sphinx package, not need sys.path.insert. + else: + newroot = path.join(testroot, path.pardir, 'build') + newroot = path.join(newroot, listdir(newroot)[0], 'tests') + # always test the sphinx package from build/lib/ + sys.path.insert(0, path.join(newroot, path.pardir)) copydir_run_2to3(testroot, newroot) # switch to the converted dir so nose tests the right tests chdir(newroot) - # always test the sphinx package from build/lib/ - sys.path.insert(0, path.pardir) else: # always test the sphinx package from this directory sys.path.insert(0, path.join(path.dirname(__file__), path.pardir)) diff --git a/tests/test_application.py b/tests/test_application.py index 4baabcec..a6e798c2 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -12,6 +12,7 @@ from StringIO import StringIO from sphinx.application import ExtensionError +from sphinx.domains import Domain from util import * @@ -69,3 +70,23 @@ def test_extensions(): assert warnings.getvalue().startswith("WARNING: extension 'shutil'") finally: app.cleanup() + +def test_domain_override(): + class A(Domain): + name = 'foo' + class B(A): + name = 'foo' + class C(Domain): + name = 'foo' + status, warnings = StringIO(), StringIO() + app = TestApp(status=status, warning=warnings) + try: + # No domain know named foo. + raises_msg(ExtensionError, 'domain foo not yet registered', + app.override_domain, A) + assert app.add_domain(A) is None + assert app.override_domain(B) is None + raises_msg(ExtensionError, 'new domain not a subclass of registered ' + 'foo domain', app.override_domain, C) + finally: + app.cleanup() |
