1655
1655
self.assertEqual('original', obj.test_attr)
1658
class TestTestCloning(tests.TestCase):
1659
"""Tests that test cloning of TestCases (as used by multiply_tests)."""
1661
def test_cloned_testcase_does_not_share_details(self):
1662
"""A TestCase cloned with clone_test does not share mutable attributes
1663
such as details or cleanups.
1665
class Test(tests.TestCase):
1667
self.addDetail('foo', Content('text/plain', lambda: 'foo'))
1668
orig_test = Test('test_foo')
1669
cloned_test = tests.clone_test(orig_test, orig_test.id() + '(cloned)')
1670
orig_test.run(unittest.TestResult())
1671
self.assertEqual('foo', orig_test.getDetails()['foo'].iter_bytes())
1672
self.assertEqual(None, cloned_test.getDetails().get('foo'))
1674
def test_double_apply_scenario_preserves_first_scenario(self):
1675
"""Applying two levels of scenarios to a test preserves the attributes
1676
added by both scenarios.
1678
class Test(tests.TestCase):
1681
test = Test('test_foo')
1682
scenarios_x = [('x=1', {'x': 1}), ('x=2', {'x': 2})]
1683
scenarios_y = [('y=1', {'y': 1}), ('y=2', {'y': 2})]
1684
suite = tests.multiply_tests(test, scenarios_x, unittest.TestSuite())
1685
suite = tests.multiply_tests(suite, scenarios_y, unittest.TestSuite())
1686
all_tests = list(tests.iter_suite_tests(suite))
1687
self.assertLength(4, all_tests)
1688
all_xys = sorted((t.x, t.y) for t in all_tests)
1689
self.assertEqual([(1, 1), (1, 2), (2, 1), (2, 2)], all_xys)
1658
1692
# NB: Don't delete this; it's not actually from 0.11!
1659
1693
@deprecated_function(deprecated_in((0, 11, 0)))
1660
1694
def sample_deprecated_function():