Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaner "raises" checking in tests #78

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion switchboard/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ def test_expirey(self):
def test_no_auto_create(self):
# without auto_create
mydict = MongoModelDict(MockModel, key='key', value='value')
pytest.raises(KeyError, lambda x: x['hello'], mydict)
with pytest.raises(KeyError):
mydict['hello']
assert MockModel.count() == 0

def test_auto_create_no_value(self):
Expand Down
12 changes: 8 additions & 4 deletions switchboard/tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ def test_decorator_for_ip_address(self):
def test():
return True

pytest.raises(HTTPNotFound, test)
with pytest.raises(HTTPNotFound):
test()

switch.status = SELECTIVE
switch.save()
Expand All @@ -170,7 +171,8 @@ def test():
condition='192.168.1.1',
)

pytest.raises(HTTPNotFound, test)
with pytest.raises(HTTPNotFound):
test()

switch.add_condition(
condition_set=condition_set,
Expand Down Expand Up @@ -203,7 +205,8 @@ def test():
condition='0-50',
)

pytest.raises(HTTPNotFound, test)
with pytest.raises(HTTPNotFound):
test()

def test_decorator_with_redirect(self):
Switch.create(
Expand All @@ -218,7 +221,8 @@ def test_decorator_with_redirect(self):
def test():
return True

pytest.raises(HTTPFound, test)
with pytest.raises(HTTPFound):
test()

def test_global(self):
switch = Switch.create(
Expand Down