diff options
Diffstat (limited to 'tests/test_websupport.py')
-rw-r--r-- | tests/test_websupport.py | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/tests/test_websupport.py b/tests/test_websupport.py index 9376a2a2..9e88a60f 100644 --- a/tests/test_websupport.py +++ b/tests/test_websupport.py @@ -9,38 +9,33 @@ :license: BSD, see LICENSE for details. """ -import os -from StringIO import StringIO +from functools import wraps -try: - from functools import wraps -except ImportError: - # functools is new in 2.5 - wraps = lambda f: (lambda w: w) +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): @@ -63,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() @@ -177,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') @@ -238,6 +233,8 @@ def test_update_username(support): called = False + + def moderation_callback(comment): global called called = True @@ -255,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']) |