Example #1
0
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

    def setUp(self):
        super(TestCaseWrapper, self).setUp()
        self.called = False
        self.wrapper = CaseWrapper(case_func=self.example_handler, parent=None)

    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), list)

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

    def test_pretty_name_property(self):
        self.assertEqual(self.wrapper.pretty_name, 'example handler')

    def test_doc_property(self):
        self.assertEqual(self.wrapper.doc, 'Test Doc String')

    def test_good_success(self):
        # Create a generic object we can use to test with
        obj = type('inline', (object,), {'success': True})
        self.wrapper.expects.append(obj)

        self.assertTrue(self.wrapper.success)

    def test_failure(self):
        # Create a generic object we can use to test with
        obj = type('inline', (object,), {'success': False})
        self.wrapper.expects.append(obj)

        self.assertFalse(self.wrapper.success)
Example #2
0
def _create_testing_spec():
    def sample_func():
        pass

    spec = Spec()
    wrapper = CaseWrapper(sample_func, spec)
    spec.cases[wrapper.id] = wrapper
    return spec, wrapper
Example #3
0
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

    def setUp(self):
        super(TestCaseWrapper, self).setUp()
        self.called = False
        self.wrapper = CaseWrapper(case_func=self.example_handler, parent=None)

    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), list)

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

    def test_pretty_name_property(self):
        self.assertEqual(self.wrapper.pretty_name, 'example handler')

    def test_doc_property(self):
        self.assertEqual(self.wrapper.doc, 'Test Doc String')

    def test_good_success(self):
        # Create a generic object we can use to test with
        obj = type('inline', (object,), {'success': True})
        self.wrapper.start()
        self.wrapper.expects.append(obj)
        self.wrapper.stop()

        self.assertTrue(self.wrapper.success)

    def test_failure(self):
        # Create a generic object we can use to test with
        obj = type('inline', (object,), {'success': False})
        self.wrapper.expects.append(obj)

        self.assertFalse(self.wrapper.success)
Example #4
0
    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), list)
Example #5
0
 def setUp(self):
     super(TestCaseWrapper, self).setUp()
     self.called = False
     self.wrapper = CaseWrapper(case_func=self.example_handler, parent=None)
Example #6
0
    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), list)
Example #7
0
 def setUp(self):
     super(TestCaseWrapper, self).setUp()
     self.called = False
     self.wrapper = CaseWrapper(case_func=self.example_handler, parent=None)