summaryrefslogtreecommitdiff
path: root/tests/test_websupport.py
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2017-01-06 00:46:42 +0900
committershimizukawa <shimizukawa@gmail.com>2017-01-06 00:46:42 +0900
commitf962ad67d230860a4fb1e04e1a9ced5629eaa524 (patch)
tree7d949833c5551a26765574fd283ab60cae041d80 /tests/test_websupport.py
parentf566f003f3a78c4bf822e97c47a45c0c605b9d2b (diff)
downloadsphinx-git-f962ad67d230860a4fb1e04e1a9ced5629eaa524.tar.gz
pytest: remove deprecated raises and raises_msg assert functions
Diffstat (limited to 'tests/test_websupport.py')
-rw-r--r--tests/test_websupport.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/tests/test_websupport.py b/tests/test_websupport.py
index af9ed91ee..3592dd5ec 100644
--- a/tests/test_websupport.py
+++ b/tests/test_websupport.py
@@ -23,7 +23,7 @@ except ImportError:
sqlalchemy_missing = True
import pytest
-from util import rootdir, tempdir, raises, skip_if
+from util import rootdir, tempdir, skip_if
@pytest.fixture
@@ -53,7 +53,8 @@ class NullStorage(StorageBackend):
@with_support(storage=NullStorage())
def test_no_srcdir(support):
# make sure the correct exception is raised if srcdir is not given.
- raises(RuntimeError, support.build)
+ with pytest.raises(RuntimeError):
+ support.build()
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
@@ -65,7 +66,8 @@ def test_build(support):
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
@with_support()
def test_get_document(support):
- raises(DocumentNotFoundError, support.get_document, 'nonexisting')
+ with pytest.raises(DocumentNotFoundError):
+ support.get_document('nonexisting')
contents = support.get_document('contents')
assert contents['title'] and contents['body'] \
@@ -90,8 +92,8 @@ def test_comments(support):
# Make sure that comments can't be added to a comment where
# displayed == False, since it could break the algorithm that
# converts a nodes comments to a tree.
- raises(CommentNotAllowedError, support.add_comment, 'Not allowed',
- parent_id=str(hidden_comment['id']))
+ with pytest.raises(CommentNotAllowedError):
+ support.add_comment('Not allowed', parent_id=str(hidden_comment['id']))
# Add a displayed and not displayed child to the displayed comment.
support.add_comment('Child test comment', parent_id=str(comment['id']),
username='user_one')
@@ -133,8 +135,8 @@ def test_user_delete_comments(support):
comment = get_comment()
assert comment['username'] == 'user_one'
# Make sure other normal users can't delete someone elses comments.
- raises(UserNotAuthorizedError, support.delete_comment,
- comment['id'], username='user_two')
+ with pytest.raises(UserNotAuthorizedError):
+ support.delete_comment(comment['id'], username='user_two')
# Now delete the comment using the correct username.
support.delete_comment(comment['id'], username='user_one')
comment = get_comment()
@@ -164,8 +166,10 @@ def test_moderation(support):
# Make sure the moderation_callback is called.
assert called
# Make sure the user must be a moderator.
- raises(UserNotAuthorizedError, support.accept_comment, accepted['id'])
- raises(UserNotAuthorizedError, support.delete_comment, deleted['id'])
+ with pytest.raises(UserNotAuthorizedError):
+ support.accept_comment(accepted['id'])
+ with pytest.raises(UserNotAuthorizedError):
+ support.delete_comment(deleted['id'])
support.accept_comment(accepted['id'], moderator=True)
support.delete_comment(deleted['id'], moderator=True)
comments = support.get_data(node.id)['comments']
@@ -186,7 +190,8 @@ def test_moderator_delete_comments(support):
comment = get_comment()
support.delete_comment(comment['id'], username='user_two',
moderator=True)
- raises(IndexError, get_comment)
+ with pytest.raises(IndexError):
+ get_comment()
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
@@ -248,8 +253,10 @@ def test_voting(support):
check_rating(2)
# Make sure a vote with value > 1 or < -1 can't be cast.
- raises(ValueError, support.process_vote, comment['id'], 'user_one', '2')
- raises(ValueError, support.process_vote, comment['id'], 'user_one', '-2')
+ with pytest.raises(ValueError):
+ support.process_vote(comment['id'], 'user_one', '2')
+ with pytest.raises(ValueError):
+ support.process_vote(comment['id'], 'user_one', '-2')
# Make sure past voting data is associated with comments when they are
# fetched.