Skip to content

Commit

Permalink
Adding a couple of basic tests to cover the assert changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmvrbanac committed Sep 25, 2013
1 parent 4aa5940 commit 8b79d96
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/test_expect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from unittest import TestCase

from specter.expect import ExpectAssert
from specter.expect import ExpectAssert, RequireAssert


class TestExpectAssertion(TestCase):
Expand Down Expand Up @@ -45,3 +45,17 @@ def test_expect_not_less_than(self):
expect = ExpectAssert(target)
expect.not_to.be_less_than(99)
self.assertTrue(expect.success)


class TestExpectAssertion(TestCase):

def test_creating_a_blank_reference(self):
target = 'test'
expect = RequireAssert(target)
self.assertEqual(expect.target, target)

def test_expect_equal(self):
target = 'test'
expect = RequireAssert(target)
expect.to.equal(target)
self.assertTrue(expect.success)
10 changes: 10 additions & 0 deletions tests/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def test_elapsed_time(self):

class TestCaseWrapper(TestCase):

def bad_handler(self, context):
print(self.object_that_doesnt_exist)

def example_handler(self, context):
"""Test Doc String"""
self.called = True
Expand All @@ -47,6 +50,13 @@ def test_execute(self):
self.wrapper.execute()
self.assertTrue(self.called)

def test_raised_exception(self):
self.wrapper = CaseWrapper(case_func=self.bad_handler, parent=None)
self.wrapper.execute()

self.assertIsNotNone(self.wrapper.error)
self.assertIs(type(self.wrapper.error), AttributeError)

def test_name_property(self):
self.assertEqual(self.wrapper.name, 'example_handler')

Expand Down

0 comments on commit 8b79d96

Please sign in to comment.