From 6b7a2c8b6ab1b191d3776b33b191ed6a5f313b47 Mon Sep 17 00:00:00 2001 From: shimizukawa Date: Sun, 15 Mar 2015 01:13:57 +0900 Subject: [PATCH] refs #1777: fix testing. first time testing always failed it means testing on travis.ci will never be succeeded. --- tests/roots/test-theming/conf.py | 2 +- tests/test_theming.py | 73 +++++++++++++++----------------- 2 files changed, 34 insertions(+), 41 deletions(-) diff --git a/tests/roots/test-theming/conf.py b/tests/roots/test-theming/conf.py index 6eecc8343..2717087d1 100644 --- a/tests/roots/test-theming/conf.py +++ b/tests/roots/test-theming/conf.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- html_theme = 'test-theme' -master = 'index' +master_doc = 'index' diff --git a/tests/test_theming.py b/tests/test_theming.py index 4e5476cb4..9b94f1c9e 100644 --- a/tests/test_theming.py +++ b/tests/test_theming.py @@ -13,7 +13,6 @@ import os import zipfile import sys import subprocess -from functools import wraps import tempfile from path import path @@ -23,34 +22,6 @@ from sphinx.util.osutil import cd from util import with_app, raises, TestApp, rootdir -def with_theme_setup(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()) - testrootdir = rootdir / 'roots' / ('test-' + root) - pkgdir = tempdir / root - testrootdir.copytree(pkgdir) - with cd(pkgdir): - command = [sys.executable, 'setup.py', 'install'] - command.extend(args) - try: - proc = subprocess.Popen( - command, - env=os.environ, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - func(pkgdir, proc) - finally: - tempdir.rmtree(ignore_errors=True) - return deco - return generator - - @with_app(confoverrides={'html_theme': 'ziptheme', 'html_theme_options.testopt': 'foo'}) def test_theme_api(app, status, warning): @@ -115,14 +86,36 @@ def test_js_source(app, status, warning): assert 'Underscore.js {v}'.format(v=v) in underscore_src, msg -@with_theme_setup('theming') -def test_theme_plugin(pkgroot, proc): - out, err = proc.communicate() - print(out) - print(err) - assert proc.returncode == 0, 'expect zero status for setup.py' - app = TestApp(testroot='theming') - try: - assert 'test-theme' in Theme.themes - finally: - app.cleanup() +def test_theme_plugin(): + tempdir = path(tempfile.mkdtemp()) + testrootdir = rootdir / 'roots' / ('test-theming') + pkgdir = tempdir / 'theming' + testrootdir.copytree(pkgdir) + with cd(pkgdir): + command = [sys.executable, 'setup.py', 'install'] + try: + proc = subprocess.Popen( + command, + env=os.environ, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + out, err = proc.communicate() + print(out) + print(err) + assert proc.returncode == 0, 'expect zero status for setup.py' + finally: + pass + + command = ['sphinx-build', '.', '_build/html'] + try: + proc = subprocess.Popen( + command, + env=os.environ, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + out, err = proc.communicate() + print(out) + print(err) + assert proc.returncode == 0, 'expect zero status for setup.py' + finally: + tempdir.rmtree(ignore_errors=True)