devtools/test/unittest_testlib.py
branchstable
changeset 5390 a40ffdce549d
parent 5389 809d3b5b3d31
child 5421 8167de96c523
equal deleted inserted replaced
5389:809d3b5b3d31 5390:a40ffdce549d
    19 class WebTestTC(TestCase):
    19 class WebTestTC(TestCase):
    20 
    20 
    21     def setUp(self):
    21     def setUp(self):
    22         output = StringIO()
    22         output = StringIO()
    23         self.runner = SkipAwareTextTestRunner(stream=output)
    23         self.runner = SkipAwareTextTestRunner(stream=output)
    24         self.output = output
    24 
    25     def test_error_raised(self):
    25     def test_error_raised(self):
    26         class MyWebTest(CubicWebTC):
    26         class MyWebTest(CubicWebTC):
    27 
    27 
    28             def test_error_view(self):
    28             def test_error_view(self):
    29                 self.request().create_entity('Bug', title=u"bt")
    29                 self.request().create_entity('Bug', title=u"bt")
    32             def test_correct_view(self):
    32             def test_correct_view(self):
    33                 self.view('primary', self.execute('CWUser U'), template=None)
    33                 self.view('primary', self.execute('CWUser U'), template=None)
    34 
    34 
    35         tests = [MyWebTest('test_error_view'), MyWebTest('test_correct_view')]
    35         tests = [MyWebTest('test_error_view'), MyWebTest('test_correct_view')]
    36         result = self.runner.run(TestSuite(tests))
    36         result = self.runner.run(TestSuite(tests))
    37         print self.output.getvalue()
       
    38         self.assertEquals(result.testsRun, 2)
    37         self.assertEquals(result.testsRun, 2)
    39         self.assertEquals(len(result.errors), 0)
    38         self.assertEquals(len(result.errors), 0)
    40         self.assertEquals(len(result.failures), 1)
    39         self.assertEquals(len(result.failures), 1)
    41         clean_repo_test_cls(MyWebTest)
    40         clean_repo_test_cls(MyWebTest)
    42 
    41