bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
1540.3.22
by Martin Pool
 [patch] Add TestCase.assertIsInstance  | 
1  | 
# Copyright (C) 2005, 2006 by Canonical Ltd
 | 
| 
1185.51.1
by Martin Pool
 Better message when failing to import a test suite.  | 
2  | 
#
 | 
3  | 
# This program is free software; you can redistribute it and/or modify
 | 
|
4  | 
# it under the terms of the GNU General Public License version 2 as published by
 | 
|
5  | 
# the Free Software Foundation.
 | 
|
6  | 
#
 | 
|
7  | 
# This program is distributed in the hope that it will be useful,
 | 
|
8  | 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|
9  | 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|
10  | 
# GNU General Public License for more details.
 | 
|
11  | 
#
 | 
|
12  | 
# You should have received a copy of the GNU General Public License
 | 
|
13  | 
# along with this program; if not, write to the Free Software
 | 
|
14  | 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|
15  | 
||
16  | 
"""Tests for the test framework
 | 
|
17  | 
"""
 | 
|
18  | 
||
19  | 
import os  | 
|
20  | 
import sys  | 
|
| 
1185.33.95
by Martin Pool
 New TestSkipped facility, and tests for it.  | 
21  | 
import unittest  | 
| 
1185.62.24
by John Arbash Meinel
 Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.  | 
22  | 
import warnings  | 
| 
1185.51.1
by Martin Pool
 Better message when failing to import a test suite.  | 
23  | 
|
| 
1534.4.25
by Robert Collins
 Add a --transport parameter to the test suite to set the default transport to be used in the test suite.  | 
24  | 
import bzrlib  | 
| 
1526.1.3
by Robert Collins
 Merge from upstream.  | 
25  | 
from bzrlib.tests import (  | 
26  | 
_load_module_by_name,  | 
|
| 
1534.4.31
by Robert Collins
 cleanedup test_outside_wt  | 
27  | 
ChrootedTestCase,  | 
| 
1526.1.3
by Robert Collins
 Merge from upstream.  | 
28  | 
TestCase,  | 
29  | 
TestCaseInTempDir,  | 
|
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
30  | 
TestCaseWithTransport,  | 
| 
1526.1.3
by Robert Collins
 Merge from upstream.  | 
31  | 
TestSkipped,  | 
32  | 
TextTestRunner,  | 
|
33  | 
                          )
 | 
|
| 
1185.62.24
by John Arbash Meinel
 Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.  | 
34  | 
import bzrlib.errors as errors  | 
| 
1185.51.1
by Martin Pool
 Better message when failing to import a test suite.  | 
35  | 
|
36  | 
||
37  | 
class SelftestTests(TestCase):  | 
|
38  | 
||
39  | 
def test_import_tests(self):  | 
|
40  | 
mod = _load_module_by_name('bzrlib.tests.test_selftest')  | 
|
41  | 
self.assertEqual(mod.SelftestTests, SelftestTests)  | 
|
42  | 
||
43  | 
def test_import_test_failure(self):  | 
|
44  | 
self.assertRaises(ImportError,  | 
|
45  | 
_load_module_by_name,  | 
|
46  | 
'bzrlib.no-name-yet')  | 
|
47  | 
||
48  | 
||
49  | 
class MetaTestLog(TestCase):  | 
|
| 
1526.1.1
by Robert Collins
 Run the test suite with no locale as well as the default locale. Also add a test for build_tree_shape to selftest.  | 
50  | 
|
| 
1185.51.1
by Martin Pool
 Better message when failing to import a test suite.  | 
51  | 
def test_logging(self):  | 
52  | 
"""Test logs are captured when a test fails."""  | 
|
53  | 
self.log('a test message')  | 
|
54  | 
self._log_file.flush()  | 
|
55  | 
self.assertContainsRe(self._get_log(), 'a test message\n')  | 
|
| 
1185.33.95
by Martin Pool
 New TestSkipped facility, and tests for it.  | 
56  | 
|
57  | 
||
| 
1526.1.1
by Robert Collins
 Run the test suite with no locale as well as the default locale. Also add a test for build_tree_shape to selftest.  | 
58  | 
class TestTreeShape(TestCaseInTempDir):  | 
59  | 
||
60  | 
def test_unicode_paths(self):  | 
|
61  | 
filename = u'hell\u00d8'  | 
|
| 
1526.1.4
by Robert Collins
 forgot my self.  | 
62  | 
try:  | 
63  | 
self.build_tree_contents([(filename, 'contents of hello')])  | 
|
64  | 
except UnicodeEncodeError:  | 
|
65  | 
raise TestSkipped("can't build unicode working tree in "  | 
|
66  | 
"filesystem encoding %s" % sys.getfilesystemencoding())  | 
|
| 
1526.1.1
by Robert Collins
 Run the test suite with no locale as well as the default locale. Also add a test for build_tree_shape to selftest.  | 
67  | 
self.failUnlessExists(filename)  | 
| 
1526.1.3
by Robert Collins
 Merge from upstream.  | 
68  | 
|
69  | 
||
| 
1185.33.95
by Martin Pool
 New TestSkipped facility, and tests for it.  | 
70  | 
class TestSkippedTest(TestCase):  | 
71  | 
"""Try running a test which is skipped, make sure it's reported properly."""  | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
72  | 
|
| 
1185.33.95
by Martin Pool
 New TestSkipped facility, and tests for it.  | 
73  | 
def test_skipped_test(self):  | 
74  | 
        # must be hidden in here so it's not run as a real test
 | 
|
75  | 
def skipping_test():  | 
|
76  | 
raise TestSkipped('test intentionally skipped')  | 
|
| 
1526.1.3
by Robert Collins
 Merge from upstream.  | 
77  | 
runner = TextTestRunner(stream=self._log_file)  | 
| 
1185.33.95
by Martin Pool
 New TestSkipped facility, and tests for it.  | 
78  | 
test = unittest.FunctionTestCase(skipping_test)  | 
79  | 
result = runner.run(test)  | 
|
80  | 
self.assertTrue(result.wasSuccessful())  | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
81  | 
|
82  | 
||
83  | 
class TestTransportProviderAdapter(TestCase):  | 
|
| 
1530.1.21
by Robert Collins
 Review feedback fixes.  | 
84  | 
"""A group of tests that test the transport implementation adaption core.  | 
85  | 
||
| 
1551.1.1
by Martin Pool
 [merge] branch-formats branch, and reconcile changes  | 
86  | 
    This is a meta test that the tests are applied to all available 
 | 
87  | 
    transports.
 | 
|
88  | 
||
| 
1530.1.21
by Robert Collins
 Review feedback fixes.  | 
89  | 
    This will be generalised in the future which is why it is in this 
 | 
90  | 
    test file even though it is specific to transport tests at the moment.
 | 
|
91  | 
    """
 | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
92  | 
|
| 
1530.1.11
by Robert Collins
 Push the transport permutations list into each transport module allowing for automatic testing of new modules that are registered as transports.  | 
93  | 
def test_get_transport_permutations(self):  | 
| 
1530.1.21
by Robert Collins
 Review feedback fixes.  | 
94  | 
        # this checks that we the module get_test_permutations call
 | 
95  | 
        # is made by the adapter get_transport_test_permitations method.
 | 
|
| 
1530.1.11
by Robert Collins
 Push the transport permutations list into each transport module allowing for automatic testing of new modules that are registered as transports.  | 
96  | 
class MockModule(object):  | 
97  | 
def get_test_permutations(self):  | 
|
98  | 
return sample_permutation  | 
|
99  | 
sample_permutation = [(1,2), (3,4)]  | 
|
100  | 
from bzrlib.transport import TransportTestProviderAdapter  | 
|
101  | 
adapter = TransportTestProviderAdapter()  | 
|
102  | 
self.assertEqual(sample_permutation,  | 
|
103  | 
adapter.get_transport_test_permutations(MockModule()))  | 
|
104  | 
||
105  | 
def test_adapter_checks_all_modules(self):  | 
|
| 
1530.1.21
by Robert Collins
 Review feedback fixes.  | 
106  | 
        # this checks that the adapter returns as many permurtations as
 | 
107  | 
        # there are in all the registered# transport modules for there
 | 
|
108  | 
        # - we assume if this matches its probably doing the right thing
 | 
|
109  | 
        # especially in combination with the tests for setting the right
 | 
|
110  | 
        # classes below.
 | 
|
| 
1530.1.11
by Robert Collins
 Push the transport permutations list into each transport module allowing for automatic testing of new modules that are registered as transports.  | 
111  | 
from bzrlib.transport import (TransportTestProviderAdapter,  | 
112  | 
                                      _get_transport_modules
 | 
|
113  | 
                                      )
 | 
|
114  | 
modules = _get_transport_modules()  | 
|
115  | 
permutation_count = 0  | 
|
116  | 
for module in modules:  | 
|
| 
1185.62.24
by John Arbash Meinel
 Changing the exception that sftp.py throws when it can't find paramiko, so that the test suite can handle it.  | 
117  | 
try:  | 
118  | 
permutation_count += len(reduce(getattr,  | 
|
119  | 
(module + ".get_test_permutations").split('.')[1:],  | 
|
120  | 
__import__(module))())  | 
|
121  | 
except errors.DependencyNotPresent:  | 
|
122  | 
                pass
 | 
|
| 
1530.1.11
by Robert Collins
 Push the transport permutations list into each transport module allowing for automatic testing of new modules that are registered as transports.  | 
123  | 
input_test = TestTransportProviderAdapter(  | 
124  | 
"test_adapter_sets_transport_class")  | 
|
125  | 
adapter = TransportTestProviderAdapter()  | 
|
126  | 
self.assertEqual(permutation_count,  | 
|
127  | 
len(list(iter(adapter.adapt(input_test)))))  | 
|
128  | 
||
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
129  | 
def test_adapter_sets_transport_class(self):  | 
| 
1540.3.21
by Martin Pool
 Trim test for TestTransportProviderAdapter to be less dependent on  | 
130  | 
        # Check that the test adapter inserts a transport and server into the
 | 
131  | 
        # generated test.
 | 
|
132  | 
        #
 | 
|
133  | 
        # This test used to know about all the possible transports and the
 | 
|
134  | 
        # order they were returned but that seems overly brittle (mbp
 | 
|
135  | 
        # 20060307)
 | 
|
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
136  | 
input_test = TestTransportProviderAdapter(  | 
137  | 
"test_adapter_sets_transport_class")  | 
|
| 
1540.3.21
by Martin Pool
 Trim test for TestTransportProviderAdapter to be less dependent on  | 
138  | 
from bzrlib.transport import TransportTestProviderAdapter  | 
| 
1530.1.1
by Robert Collins
 Minimal infrastructure to test TransportTestProviderAdapter.  | 
139  | 
suite = TransportTestProviderAdapter().adapt(input_test)  | 
| 
1540.3.21
by Martin Pool
 Trim test for TestTransportProviderAdapter to be less dependent on  | 
140  | 
tests = list(iter(suite))  | 
141  | 
self.assertTrue(len(tests) > 6)  | 
|
142  | 
        # there are at least that many builtin transports
 | 
|
143  | 
one_test = tests[0]  | 
|
144  | 
self.assertTrue(issubclass(one_test.transport_class,  | 
|
145  | 
bzrlib.transport.Transport))  | 
|
146  | 
self.assertTrue(issubclass(one_test.transport_server,  | 
|
147  | 
bzrlib.transport.Server))  | 
|
| 
1534.4.3
by Robert Collins
 Implement BranchTestProviderAdapter, so tests now run across all branch formats.  | 
148  | 
|
149  | 
||
150  | 
class TestBranchProviderAdapter(TestCase):  | 
|
151  | 
"""A group of tests that test the branch implementation test adapter."""  | 
|
152  | 
||
153  | 
def test_adapted_tests(self):  | 
|
154  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
155  | 
        # test.
 | 
|
156  | 
from bzrlib.branch import BranchTestProviderAdapter  | 
|
157  | 
input_test = TestBranchProviderAdapter(  | 
|
158  | 
"test_adapted_tests")  | 
|
159  | 
server1 = "a"  | 
|
160  | 
server2 = "b"  | 
|
| 
1534.4.41
by Robert Collins
 Branch now uses BzrDir reasonably sanely.  | 
161  | 
formats = [("c", "C"), ("d", "D")]  | 
| 
1534.4.3
by Robert Collins
 Implement BranchTestProviderAdapter, so tests now run across all branch formats.  | 
162  | 
adapter = BranchTestProviderAdapter(server1, server2, formats)  | 
163  | 
suite = adapter.adapt(input_test)  | 
|
164  | 
tests = list(iter(suite))  | 
|
165  | 
self.assertEqual(2, len(tests))  | 
|
| 
1534.4.41
by Robert Collins
 Branch now uses BzrDir reasonably sanely.  | 
166  | 
self.assertEqual(tests[0].branch_format, formats[0][0])  | 
167  | 
self.assertEqual(tests[0].bzrdir_format, formats[0][1])  | 
|
| 
1534.4.3
by Robert Collins
 Implement BranchTestProviderAdapter, so tests now run across all branch formats.  | 
168  | 
self.assertEqual(tests[0].transport_server, server1)  | 
169  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
| 
1534.4.41
by Robert Collins
 Branch now uses BzrDir reasonably sanely.  | 
170  | 
self.assertEqual(tests[1].branch_format, formats[1][0])  | 
171  | 
self.assertEqual(tests[1].bzrdir_format, formats[1][1])  | 
|
| 
1534.4.3
by Robert Collins
 Implement BranchTestProviderAdapter, so tests now run across all branch formats.  | 
172  | 
self.assertEqual(tests[1].transport_server, server1)  | 
173  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
174  | 
|
175  | 
||
| 
1534.4.39
by Robert Collins
 Basic BzrDir support.  | 
176  | 
class TestBzrDirProviderAdapter(TestCase):  | 
177  | 
"""A group of tests that test the bzr dir implementation test adapter."""  | 
|
178  | 
||
179  | 
def test_adapted_tests(self):  | 
|
180  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
181  | 
        # test.
 | 
|
182  | 
from bzrlib.bzrdir import BzrDirTestProviderAdapter  | 
|
183  | 
input_test = TestBzrDirProviderAdapter(  | 
|
184  | 
"test_adapted_tests")  | 
|
185  | 
server1 = "a"  | 
|
186  | 
server2 = "b"  | 
|
187  | 
formats = ["c", "d"]  | 
|
188  | 
adapter = BzrDirTestProviderAdapter(server1, server2, formats)  | 
|
189  | 
suite = adapter.adapt(input_test)  | 
|
190  | 
tests = list(iter(suite))  | 
|
191  | 
self.assertEqual(2, len(tests))  | 
|
192  | 
self.assertEqual(tests[0].bzrdir_format, formats[0])  | 
|
193  | 
self.assertEqual(tests[0].transport_server, server1)  | 
|
194  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
195  | 
self.assertEqual(tests[1].bzrdir_format, formats[1])  | 
|
196  | 
self.assertEqual(tests[1].transport_server, server1)  | 
|
197  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
198  | 
||
199  | 
||
| 
1534.4.40
by Robert Collins
 Add RepositoryFormats and allow bzrdir.open or create _repository to be used.  | 
200  | 
class TestRepositoryProviderAdapter(TestCase):  | 
201  | 
"""A group of tests that test the repository implementation test adapter."""  | 
|
202  | 
||
203  | 
def test_adapted_tests(self):  | 
|
204  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
205  | 
        # test.
 | 
|
206  | 
from bzrlib.repository import RepositoryTestProviderAdapter  | 
|
207  | 
input_test = TestRepositoryProviderAdapter(  | 
|
208  | 
"test_adapted_tests")  | 
|
209  | 
server1 = "a"  | 
|
210  | 
server2 = "b"  | 
|
211  | 
formats = [("c", "C"), ("d", "D")]  | 
|
212  | 
adapter = RepositoryTestProviderAdapter(server1, server2, formats)  | 
|
213  | 
suite = adapter.adapt(input_test)  | 
|
214  | 
tests = list(iter(suite))  | 
|
215  | 
self.assertEqual(2, len(tests))  | 
|
216  | 
self.assertEqual(tests[0].bzrdir_format, formats[0][1])  | 
|
217  | 
self.assertEqual(tests[0].repository_format, formats[0][0])  | 
|
218  | 
self.assertEqual(tests[0].transport_server, server1)  | 
|
219  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
220  | 
self.assertEqual(tests[1].bzrdir_format, formats[1][1])  | 
|
221  | 
self.assertEqual(tests[1].repository_format, formats[1][0])  | 
|
222  | 
self.assertEqual(tests[1].transport_server, server1)  | 
|
223  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
224  | 
||
225  | 
||
| 
1534.1.29
by Robert Collins
 Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.  | 
226  | 
class TestInterRepositoryProviderAdapter(TestCase):  | 
227  | 
"""A group of tests that test the InterRepository test adapter."""  | 
|
228  | 
||
229  | 
def test_adapted_tests(self):  | 
|
230  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
231  | 
        # test.
 | 
|
232  | 
from bzrlib.repository import InterRepositoryTestProviderAdapter  | 
|
233  | 
input_test = TestInterRepositoryProviderAdapter(  | 
|
234  | 
"test_adapted_tests")  | 
|
235  | 
server1 = "a"  | 
|
236  | 
server2 = "b"  | 
|
| 
1563.2.20
by Robert Collins
 Add a revision store test adapter.  | 
237  | 
formats = [(str, "C1", "C2"), (int, "D1", "D2")]  | 
| 
1534.1.29
by Robert Collins
 Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.  | 
238  | 
adapter = InterRepositoryTestProviderAdapter(server1, server2, formats)  | 
239  | 
suite = adapter.adapt(input_test)  | 
|
240  | 
tests = list(iter(suite))  | 
|
241  | 
self.assertEqual(2, len(tests))  | 
|
242  | 
self.assertEqual(tests[0].interrepo_class, formats[0][0])  | 
|
243  | 
self.assertEqual(tests[0].repository_format, formats[0][1])  | 
|
244  | 
self.assertEqual(tests[0].repository_format_to, formats[0][2])  | 
|
245  | 
self.assertEqual(tests[0].transport_server, server1)  | 
|
246  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
| 
1563.2.20
by Robert Collins
 Add a revision store test adapter.  | 
247  | 
self.assertEqual(tests[1].interrepo_class, formats[1][0])  | 
| 
1534.1.29
by Robert Collins
 Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.  | 
248  | 
self.assertEqual(tests[1].repository_format, formats[1][1])  | 
249  | 
self.assertEqual(tests[1].repository_format_to, formats[1][2])  | 
|
250  | 
self.assertEqual(tests[1].transport_server, server1)  | 
|
251  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
252  | 
||
253  | 
||
| 
1563.2.12
by Robert Collins
 Checkpointing: created InterObject to factor out common inter object worker code, added InterVersionedFile and tests to allow making join work between any versionedfile.  | 
254  | 
class TestInterVersionedFileProviderAdapter(TestCase):  | 
255  | 
"""A group of tests that test the InterVersionedFile test adapter."""  | 
|
256  | 
||
257  | 
def test_adapted_tests(self):  | 
|
258  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
259  | 
        # test.
 | 
|
260  | 
from bzrlib.versionedfile import InterVersionedFileTestProviderAdapter  | 
|
261  | 
input_test = TestInterRepositoryProviderAdapter(  | 
|
262  | 
"test_adapted_tests")  | 
|
263  | 
server1 = "a"  | 
|
264  | 
server2 = "b"  | 
|
| 
1563.2.20
by Robert Collins
 Add a revision store test adapter.  | 
265  | 
formats = [(str, "C1", "C2"), (int, "D1", "D2")]  | 
| 
1563.2.12
by Robert Collins
 Checkpointing: created InterObject to factor out common inter object worker code, added InterVersionedFile and tests to allow making join work between any versionedfile.  | 
266  | 
adapter = InterVersionedFileTestProviderAdapter(server1, server2, formats)  | 
267  | 
suite = adapter.adapt(input_test)  | 
|
268  | 
tests = list(iter(suite))  | 
|
269  | 
self.assertEqual(2, len(tests))  | 
|
270  | 
self.assertEqual(tests[0].interversionedfile_class, formats[0][0])  | 
|
271  | 
self.assertEqual(tests[0].versionedfile_factory, formats[0][1])  | 
|
272  | 
self.assertEqual(tests[0].versionedfile_factory_to, formats[0][2])  | 
|
273  | 
self.assertEqual(tests[0].transport_server, server1)  | 
|
274  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
| 
1563.2.20
by Robert Collins
 Add a revision store test adapter.  | 
275  | 
self.assertEqual(tests[1].interversionedfile_class, formats[1][0])  | 
| 
1563.2.12
by Robert Collins
 Checkpointing: created InterObject to factor out common inter object worker code, added InterVersionedFile and tests to allow making join work between any versionedfile.  | 
276  | 
self.assertEqual(tests[1].versionedfile_factory, formats[1][1])  | 
277  | 
self.assertEqual(tests[1].versionedfile_factory_to, formats[1][2])  | 
|
278  | 
self.assertEqual(tests[1].transport_server, server1)  | 
|
279  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
280  | 
||
281  | 
||
| 
1563.2.20
by Robert Collins
 Add a revision store test adapter.  | 
282  | 
class TestRevisionStoreProviderAdapter(TestCase):  | 
283  | 
"""A group of tests that test the RevisionStore test adapter."""  | 
|
284  | 
||
285  | 
def test_adapted_tests(self):  | 
|
286  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
287  | 
        # test.
 | 
|
288  | 
from bzrlib.store.revision import RevisionStoreTestProviderAdapter  | 
|
289  | 
input_test = TestRevisionStoreProviderAdapter(  | 
|
290  | 
"test_adapted_tests")  | 
|
291  | 
        # revision stores need a store factory - i.e. RevisionKnit
 | 
|
292  | 
        #, a readonly and rw transport 
 | 
|
293  | 
        # transport servers:
 | 
|
294  | 
server1 = "a"  | 
|
295  | 
server2 = "b"  | 
|
296  | 
store_factories = ["c", "d"]  | 
|
297  | 
adapter = RevisionStoreTestProviderAdapter(server1, server2, store_factories)  | 
|
298  | 
suite = adapter.adapt(input_test)  | 
|
299  | 
tests = list(iter(suite))  | 
|
300  | 
self.assertEqual(2, len(tests))  | 
|
301  | 
self.assertEqual(tests[0].store_factory, store_factories[0][0])  | 
|
302  | 
self.assertEqual(tests[0].transport_server, server1)  | 
|
303  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
304  | 
self.assertEqual(tests[1].store_factory, store_factories[1][0])  | 
|
305  | 
self.assertEqual(tests[1].transport_server, server1)  | 
|
306  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
307  | 
||
308  | 
||
| 
1534.4.46
by Robert Collins
 Nearly complete .bzr/checkout splitout.  | 
309  | 
class TestWorkingTreeProviderAdapter(TestCase):  | 
310  | 
"""A group of tests that test the workingtree implementation test adapter."""  | 
|
311  | 
||
312  | 
def test_adapted_tests(self):  | 
|
313  | 
        # check that constructor parameters are passed through to the adapted
 | 
|
314  | 
        # test.
 | 
|
315  | 
from bzrlib.workingtree import WorkingTreeTestProviderAdapter  | 
|
316  | 
input_test = TestWorkingTreeProviderAdapter(  | 
|
317  | 
"test_adapted_tests")  | 
|
318  | 
server1 = "a"  | 
|
319  | 
server2 = "b"  | 
|
320  | 
formats = [("c", "C"), ("d", "D")]  | 
|
321  | 
adapter = WorkingTreeTestProviderAdapter(server1, server2, formats)  | 
|
322  | 
suite = adapter.adapt(input_test)  | 
|
323  | 
tests = list(iter(suite))  | 
|
324  | 
self.assertEqual(2, len(tests))  | 
|
325  | 
self.assertEqual(tests[0].workingtree_format, formats[0][0])  | 
|
326  | 
self.assertEqual(tests[0].bzrdir_format, formats[0][1])  | 
|
327  | 
self.assertEqual(tests[0].transport_server, server1)  | 
|
328  | 
self.assertEqual(tests[0].transport_readonly_server, server2)  | 
|
329  | 
self.assertEqual(tests[1].workingtree_format, formats[1][0])  | 
|
330  | 
self.assertEqual(tests[1].bzrdir_format, formats[1][1])  | 
|
331  | 
self.assertEqual(tests[1].transport_server, server1)  | 
|
332  | 
self.assertEqual(tests[1].transport_readonly_server, server2)  | 
|
333  | 
||
334  | 
||
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
335  | 
class TestTestCaseWithTransport(TestCaseWithTransport):  | 
336  | 
"""Tests for the convenience functions TestCaseWithTransport introduces."""  | 
|
337  | 
||
338  | 
def test_get_readonly_url_none(self):  | 
|
339  | 
from bzrlib.transport import get_transport  | 
|
340  | 
from bzrlib.transport.memory import MemoryServer  | 
|
341  | 
from bzrlib.transport.readonly import ReadonlyTransportDecorator  | 
|
342  | 
self.transport_server = MemoryServer  | 
|
343  | 
self.transport_readonly_server = None  | 
|
344  | 
        # calling get_readonly_transport() constructs a decorator on the url
 | 
|
345  | 
        # for the server
 | 
|
346  | 
url = self.get_readonly_url()  | 
|
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
347  | 
url2 = self.get_readonly_url('foo/bar')  | 
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
348  | 
t = get_transport(url)  | 
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
349  | 
t2 = get_transport(url2)  | 
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
350  | 
self.failUnless(isinstance(t, ReadonlyTransportDecorator))  | 
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
351  | 
self.failUnless(isinstance(t2, ReadonlyTransportDecorator))  | 
352  | 
self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))  | 
|
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
353  | 
|
354  | 
def test_get_readonly_url_http(self):  | 
|
355  | 
from bzrlib.transport import get_transport  | 
|
356  | 
from bzrlib.transport.local import LocalRelpathServer  | 
|
| 
1540.3.6
by Martin Pool
 [merge] update from bzr.dev  | 
357  | 
from bzrlib.transport.http import HttpServer, HttpTransportBase  | 
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
358  | 
self.transport_server = LocalRelpathServer  | 
359  | 
self.transport_readonly_server = HttpServer  | 
|
360  | 
        # calling get_readonly_transport() gives us a HTTP server instance.
 | 
|
361  | 
url = self.get_readonly_url()  | 
|
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
362  | 
url2 = self.get_readonly_url('foo/bar')  | 
| 
1540.3.6
by Martin Pool
 [merge] update from bzr.dev  | 
363  | 
        # the transport returned may be any HttpTransportBase subclass
 | 
| 
1534.4.10
by Robert Collins
 Add TestCaseWithTransport class that provides tests with read and write transport pairs.  | 
364  | 
t = get_transport(url)  | 
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
365  | 
t2 = get_transport(url2)  | 
| 
1540.3.6
by Martin Pool
 [merge] update from bzr.dev  | 
366  | 
self.failUnless(isinstance(t, HttpTransportBase))  | 
367  | 
self.failUnless(isinstance(t2, HttpTransportBase))  | 
|
| 
1534.4.11
by Robert Collins
 Convert test_open_containing from being a Remote test to being the more accurate Chrooted test.  | 
368  | 
self.assertEqual(t2.base[:-1], t.abspath('foo/bar'))  | 
| 
1534.4.31
by Robert Collins
 cleanedup test_outside_wt  | 
369  | 
|
| 
1553.5.68
by Martin Pool
 Add new TestCaseWithTransport.assertIsDirectory() and tests  | 
370  | 
def test_is_directory(self):  | 
371  | 
"""Test assertIsDirectory assertion"""  | 
|
372  | 
t = self.get_transport()  | 
|
373  | 
self.build_tree(['a_dir/', 'a_file'], transport=t)  | 
|
374  | 
self.assertIsDirectory('a_dir', t)  | 
|
375  | 
self.assertRaises(AssertionError, self.assertIsDirectory, 'a_file', t)  | 
|
376  | 
self.assertRaises(AssertionError, self.assertIsDirectory, 'not_here', t)  | 
|
| 
1534.4.31
by Robert Collins
 cleanedup test_outside_wt  | 
377  | 
|
| 
1666.1.4
by Robert Collins
 * 'Metadir' is now the default disk format. This improves behaviour in  | 
378  | 
|
| 
1534.4.31
by Robert Collins
 cleanedup test_outside_wt  | 
379  | 
class TestChrootedTest(ChrootedTestCase):  | 
380  | 
||
381  | 
def test_root_is_root(self):  | 
|
382  | 
from bzrlib.transport import get_transport  | 
|
383  | 
t = get_transport(self.get_readonly_url())  | 
|
384  | 
url = t.base  | 
|
385  | 
self.assertEqual(url, t.clone('..').base)  | 
|
| 
1540.3.22
by Martin Pool
 [patch] Add TestCase.assertIsInstance  | 
386  | 
|
387  | 
||
388  | 
class TestExtraAssertions(TestCase):  | 
|
389  | 
"""Tests for new test assertions in bzrlib test suite"""  | 
|
390  | 
||
391  | 
def test_assert_isinstance(self):  | 
|
392  | 
self.assertIsInstance(2, int)  | 
|
393  | 
self.assertIsInstance(u'', basestring)  | 
|
394  | 
self.assertRaises(AssertionError, self.assertIsInstance, None, int)  | 
|
395  | 
self.assertRaises(AssertionError, self.assertIsInstance, 23.3, int)  | 
|
| 
1666.1.4
by Robert Collins
 * 'Metadir' is now the default disk format. This improves behaviour in  | 
396  | 
|
| 
1692.3.1
by Robert Collins
 Fix push to work with just a branch, no need for a working tree.  | 
397  | 
def test_assertEndsWith(self):  | 
398  | 
self.assertEndsWith('foo', 'oo')  | 
|
399  | 
self.assertRaises(AssertionError, self.assertEndsWith, 'o', 'oo')  | 
|
400  | 
||
| 
1666.1.4
by Robert Collins
 * 'Metadir' is now the default disk format. This improves behaviour in  | 
401  | 
|
402  | 
class TestConvenienceMakers(TestCaseWithTransport):  | 
|
403  | 
"""Test for the make_* convenience functions."""  | 
|
404  | 
||
405  | 
def test_make_branch_and_tree_with_format(self):  | 
|
406  | 
        # we should be able to supply a format to make_branch_and_tree
 | 
|
407  | 
self.make_branch_and_tree('a', format=bzrlib.bzrdir.BzrDirMetaFormat1())  | 
|
408  | 
self.make_branch_and_tree('b', format=bzrlib.bzrdir.BzrDirFormat6())  | 
|
409  | 
self.assertIsInstance(bzrlib.bzrdir.BzrDir.open('a')._format,  | 
|
410  | 
bzrlib.bzrdir.BzrDirMetaFormat1)  | 
|
411  | 
self.assertIsInstance(bzrlib.bzrdir.BzrDir.open('b')._format,  | 
|
412  | 
bzrlib.bzrdir.BzrDirFormat6)  |