summaryrefslogtreecommitdiff
path: root/tests/test_websupport.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-09-21 17:17:02 +0200
committerGeorg Brandl <georg@python.org>2014-09-21 17:17:02 +0200
commitd47a7587f9813f2366e2077be051116291bf930e (patch)
tree08d92669490358b284d2edd9ba4d61b64c52042a /tests/test_websupport.py
parentc5dfd5c7328fe642d0ca2bb51be58253326af17f (diff)
downloadsphinx-git-d47a7587f9813f2366e2077be051116291bf930e.tar.gz
Complete test suite overhaul.
* rename a few test modules to make the names more consistent * do not copy/use Sphinx from build/ (unnecessary without 2to3) * use a temporary dir for *all* test projects, the source tree will stay pristine that way (default is tests/build) * speed up tests by ~3x by splitting up test projects and avoiding rebuilds
Diffstat (limited to 'tests/test_websupport.py')
-rw-r--r--tests/test_websupport.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/tests/test_websupport.py b/tests/test_websupport.py
index d355422c9..9e88a60fe 100644
--- a/tests/test_websupport.py
+++ b/tests/test_websupport.py
@@ -9,34 +9,33 @@
:license: BSD, see LICENSE for details.
"""
-import os
from functools import wraps
from six import StringIO
from sphinx.websupport import WebSupport
from sphinx.websupport.errors import DocumentNotFoundError, \
- CommentNotAllowedError, UserNotAuthorizedError
+ CommentNotAllowedError, UserNotAuthorizedError
from sphinx.websupport.storage import StorageBackend
from sphinx.websupport.storage.differ import CombinedHtmlDiff
try:
from sphinx.websupport.storage.sqlalchemystorage import Session, \
- Comment, CommentVote
+ Comment, CommentVote
from sphinx.websupport.storage.sqlalchemy_db import Node
sqlalchemy_missing = False
except ImportError:
sqlalchemy_missing = True
-from util import test_root, raises, skip_if
+from util import rootdir, tempdir, raises, skip_if
-default_settings = {'builddir': os.path.join(test_root, 'websupport'),
+default_settings = {'builddir': tempdir / 'websupport',
'status': StringIO(),
'warning': StringIO()}
+
def teardown_module():
- (test_root / 'generated').rmtree(True)
- (test_root / 'websupport').rmtree(True)
+ (tempdir / 'websupport').rmtree(True)
def with_support(*args, **kwargs):
@@ -59,12 +58,12 @@ class NullStorage(StorageBackend):
@with_support(storage=NullStorage())
def test_no_srcdir(support):
- """Make sure the correct exception is raised if srcdir is not given."""
+ # make sure the correct exception is raised if srcdir is not given.
raises(RuntimeError, support.build)
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
-@with_support(srcdir=test_root)
+@with_support(srcdir=rootdir / 'root')
def test_build(support):
support.build()
@@ -173,9 +172,9 @@ def test_proposals(support):
source = data['source']
proposal = source[:5] + source[10:15] + 'asdf' + source[15:]
- comment = support.add_comment('Proposal comment',
- node_id=node.id,
- proposal=proposal)
+ support.add_comment('Proposal comment',
+ node_id=node.id,
+ proposal=proposal)
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
@@ -234,6 +233,8 @@ def test_update_username(support):
called = False
+
+
def moderation_callback(comment):
global called
called = True
@@ -251,7 +252,7 @@ def test_moderation(support):
deleted = support.add_comment('Comment to delete', node_id=node.id,
displayed=False)
# Make sure the moderation_callback is called.
- assert called == True
+ assert called
# Make sure the user must be a moderator.
raises(UserNotAuthorizedError, support.accept_comment, accepted['id'])
raises(UserNotAuthorizedError, support.delete_comment, deleted['id'])