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

Adding tests for assertions that don't accept a msg argument #91

Open
wants to merge 1 commit into
base: bug/deprecated-assertion-methods
Choose a base branch
from
Open
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
44 changes: 43 additions & 1 deletion marbles/core/tests/test_marbles.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ def test_deprecated_assertEquals_failure_with_note(self):
y = 2
self.assertEquals(x, y, note='x should equal y')

# When assertRaises (and assertWarns, assertRaisesRegex, and
# assertWarnsRegex) aren't used as contex managers, they don't
# accept a msg argument
def test_assertion_without_msg_success(self):
self.assertRaises(self.failureException,
self.assertAlmostEqual, 1.0000001, 1.0)

def test_assertion_without_msg_failure(self):
self.assertRaises(self.failureException,
self.assertAlmostEqual, 1.0000000, 1.0)

def test_assertion_without_msg_success_with_note(self):
self.assertRaises(self.failureException,
self.assertAlmostEqual, 1.0000001, 1.0,
note='some note')

def test_assertion_without_msg_failure_with_note(self):
self.assertRaises(self.failureException,
self.assertAlmostEqual, 1.0000000, 1.0,
note='some note')

def test_fail_without_msg_without_note(self):
self.fail()

Expand Down Expand Up @@ -388,6 +409,27 @@ def test_deprecated_assertEquals_failure(self):
with self.assertRaises(ContextualAssertionError):
self.case.test_deprecated_assertEquals_failure_with_note()

def test_assertion_without_msg_success(self):
if self._use_annotated_test_case:
with self.assertRaises(AnnotationError):
self.case.test_assertion_without_msg_success()
self.case.test_assertion_without_msg_success_with_note()
else:
self.case.test_assertion_without_msg_success()
self.case.test_assertion_without_msg_success_with_note()

def test_assertion_without_msg_failure(self):
if self._use_annotated_test_case:
with self.assertRaises(AnnotationError):
self.case.test_assertion_without_msg_failure()
with self.assertRaises(ContextualAssertionError):
self.case.test_assertion_without_msg_failure_with_note()
else:
with self.assertRaises(ContextualAssertionError):
self.case.test_assertion_without_msg_failure()
with self.assertRaises(ContextualAssertionError):
self.case.test_assertion_without_msg_failure_with_note()

def test_fail_handles_note_properly(self):
'''Does TestCase.fail() deal with note the right way?'''
if self._use_annotated_test_case:
Expand Down Expand Up @@ -558,7 +600,7 @@ def test_get_stack(self):
self.assertEqual(e.filename, os.path.abspath(__file__))
# This isn't great because I have to change it every time I
# add/remove imports but oh well
self.assertEqual(e.linenumber, 231)
self.assertEqual(e.linenumber, 252)

def test_assert_stmt_indicates_line(self):
'''Does e.assert_stmt indicate the line from the source code?'''
Expand Down