Skip to content

Commit c3fccbd

Browse files
committed
Update comments and add assert_raises()
1 parent 01cd41c commit c3fccbd

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

help_docs/method_summary.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ self.assert_equal(first, second, msg=None)
268268

269269
self.assert_not_equal(first, second, msg=None)
270270

271+
self.assert_raises(*args, **kwargs)
272+
271273
self.assert_title(title)
272274

273275
self.assert_no_js_errors()

seleniumbase/fixtures/base_case.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,32 +2422,34 @@ def assert_downloaded_file(self, file):
24222422
self.driver, messenger_post, self.message_duration)
24232423

24242424
def assert_true(self, expr, msg=None):
2425+
""" Asserts that the expression is True.
2426+
Will raise an exception if the statement if False. """
24252427
self.assertTrue(expr, msg=msg)
2426-
'''if self.demo_mode:
2427-
messenger_post = ("ASSERT TRUE (See code)")
2428-
js_utils.post_messenger_success_message(
2429-
self.driver, messenger_post, self.message_duration)'''
24302428

24312429
def assert_false(self, expr, msg=None):
2430+
""" Asserts that the expression is False.
2431+
Will raise an exception if the statement if True. """
24322432
self.assertFalse(expr, msg=msg)
2433-
'''if self.demo_mode:
2434-
messenger_post = ("ASSERT FALSE (See code)")
2435-
js_utils.post_messenger_success_message(
2436-
self.driver, messenger_post, self.message_duration)'''
24372433

24382434
def assert_equal(self, first, second, msg=None):
2435+
""" Asserts that the two values are equal.
2436+
Will raise an exception if the values are not equal. """
24392437
self.assertEqual(first, second, msg=msg)
2440-
'''if self.demo_mode:
2441-
messenger_post = ("ASSERT EQUAL: {%s == %s}" % (first, second))
2442-
js_utils.post_messenger_success_message(
2443-
self.driver, messenger_post, self.message_duration)'''
24442438

24452439
def assert_not_equal(self, first, second, msg=None):
2440+
""" Asserts that the two values are not equal.
2441+
Will raise an exception if the values are equal. """
24462442
self.assertNotEqual(first, second, msg=msg)
2447-
'''if self.demo_mode:
2448-
messenger_post = ("ASSERT NOT EQUAL: {%s != %s}" % (first, second))
2449-
js_utils.post_messenger_success_message(
2450-
self.driver, messenger_post, self.message_duration)'''
2443+
2444+
def assert_raises(self, *args, **kwargs):
2445+
""" Asserts that the following block of code raises an exception.
2446+
Will raise an exception if the block of code has no exception.
2447+
Usage Example =>
2448+
# Verify that the expected exception is raised.
2449+
with self.assert_raises(Exception):
2450+
raise Exception("Expected Exception!")
2451+
"""
2452+
self.assertRaises(*args, **kwargs)
24512453

24522454
def assert_title(self, title):
24532455
""" Asserts that the web page title matches the expected title. """

0 commit comments

Comments
 (0)