Skip to content

Commit

Permalink
Adding tests for #78
Browse files Browse the repository at this point in the history
  • Loading branch information
thejunglejane committed Aug 20, 2018
1 parent 0784a81 commit 8ad6773
Showing 1 changed file with 43 additions and 1 deletion.
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

0 comments on commit 8ad6773

Please sign in to comment.