326
326
from bzrlib.tests.per_interrepository import make_scenarios
329
formats = [("C0", "C1", "C2"), ("D0", "D1", "D2")]
329
formats = [("C0", "C1", "C2", "C3"), ("D0", "D1", "D2", "D3")]
330
330
scenarios = make_scenarios(server1, server2, formats)
331
331
self.assertEqual([
333
333
{'repository_format': 'C1',
334
334
'repository_format_to': 'C2',
335
335
'transport_readonly_server': 'b',
336
'transport_server': 'a'}),
336
'transport_server': 'a',
337
'extra_setup': 'C3'}),
338
339
{'repository_format': 'D1',
339
340
'repository_format_to': 'D2',
340
341
'transport_readonly_server': 'b',
341
'transport_server': 'a'})],
342
'transport_server': 'a',
343
'extra_setup': 'D3'})],
1676
1678
self.assertEqual('original', obj.test_attr)
1681
class TestTestCloning(tests.TestCase):
1682
"""Tests that test cloning of TestCases (as used by multiply_tests)."""
1684
def test_cloned_testcase_does_not_share_details(self):
1685
"""A TestCase cloned with clone_test does not share mutable attributes
1686
such as details or cleanups.
1688
class Test(tests.TestCase):
1690
self.addDetail('foo', Content('text/plain', lambda: 'foo'))
1691
orig_test = Test('test_foo')
1692
cloned_test = tests.clone_test(orig_test, orig_test.id() + '(cloned)')
1693
orig_test.run(unittest.TestResult())
1694
self.assertEqual('foo', orig_test.getDetails()['foo'].iter_bytes())
1695
self.assertEqual(None, cloned_test.getDetails().get('foo'))
1697
def test_double_apply_scenario_preserves_first_scenario(self):
1698
"""Applying two levels of scenarios to a test preserves the attributes
1699
added by both scenarios.
1701
class Test(tests.TestCase):
1704
test = Test('test_foo')
1705
scenarios_x = [('x=1', {'x': 1}), ('x=2', {'x': 2})]
1706
scenarios_y = [('y=1', {'y': 1}), ('y=2', {'y': 2})]
1707
suite = tests.multiply_tests(test, scenarios_x, unittest.TestSuite())
1708
suite = tests.multiply_tests(suite, scenarios_y, unittest.TestSuite())
1709
all_tests = list(tests.iter_suite_tests(suite))
1710
self.assertLength(4, all_tests)
1711
all_xys = sorted((t.x, t.y) for t in all_tests)
1712
self.assertEqual([(1, 1), (1, 2), (2, 1), (2, 2)], all_xys)
1679
1715
# NB: Don't delete this; it's not actually from 0.11!
1680
1716
@deprecated_function(deprecated_in((0, 11, 0)))
1681
1717
def sample_deprecated_function():