def test_useFixture(self): parent = LoggingFixture('-outer') nested = LoggingFixture('-inner', calls=parent.calls) parent.setUp() parent.useFixture(nested) parent.cleanUp() self.assertEqual( ['setUp-outer', 'setUp-inner', 'cleanUp-inner', 'cleanUp-outer'], parent.calls)
def test_reset_called(self): fixture = LoggingFixture() mgr = testresources.FixtureResource(fixture) resource = mgr.getResource() mgr.reset(resource) mgr.finishedWith(resource) self.assertEqual(['setUp', 'reset', 'cleanUp'], fixture.calls)
def test_uses_setUp_cleanUp(self): fixture = LoggingFixture() mgr = testresources.FixtureResource(fixture) resource = mgr.getResource() self.assertEqual(fixture, resource) self.assertEqual(['setUp'], fixture.calls) mgr.finishedWith(resource) self.assertEqual(['setUp', 'cleanUp'], fixture.calls)
def test_useFixture(self): fixture = LoggingFixture() class SimpleTest(testtools.TestCase, TestWithFixtures): def test_foo(self): self.useFixture(fixture) result = unittest.TestResult() SimpleTest('test_foo').run(result) self.assertTrue(result.wasSuccessful()) self.assertEqual(['setUp', 'cleanUp'], fixture.calls)
def test_always_dirty(self): fixture = LoggingFixture() mgr = testresources.FixtureResource(fixture) resource = mgr.getResource() self.assertTrue(mgr.isDirty()) mgr.finishedWith(resource)