~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.py

  • Committer: John Arbash Meinel
  • Date: 2009-09-24 19:26:45 UTC
  • mto: (4634.52.3 2.0)
  • mto: This revision was merged to the branch mainline in revision 4716.
  • Revision ID: john@arbash-meinel.com-20090924192645-hyy1ycnnk6u3j5j6
Catch a corner case that we were missing.
The CHKInventory tests were passing, but failed for test_inv because
we were passing None to _getitems(). That only failed for InternalNodes,
but we were using a structure that didn't have internal nodes.
So now the test is parameterized on a small CHKInventory page size
to force those things out into the open.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1830
1830
        """
1831
1831
        from bzrlib.tests.blackbox.test_push import RedirectingMemoryServer
1832
1832
        server = RedirectingMemoryServer()
1833
 
        self.start_server(server)
 
1833
        server.setUp()
1834
1834
        url = server.get_url() + 'infinite-loop'
 
1835
        self.addCleanup(server.tearDown)
1835
1836
        self.assertRaises(errors.NotABundle, read_mergeable_from_url, url)
1836
1837
 
1837
1838
    def test_smart_server_connection_reset(self):
1840
1841
        """
1841
1842
        # Instantiate a server that will provoke a ConnectionReset
1842
1843
        sock_server = _DisconnectingTCPServer()
1843
 
        self.start_server(sock_server)
 
1844
        sock_server.setUp()
 
1845
        self.addCleanup(sock_server.tearDown)
1844
1846
        # We don't really care what the url is since the server will close the
1845
1847
        # connection without interpreting it
1846
1848
        url = sock_server.get_url()
1850
1852
class _DisconnectingTCPServer(object):
1851
1853
    """A TCP server that immediately closes any connection made to it."""
1852
1854
 
1853
 
    def start_server(self):
 
1855
    def setUp(self):
1854
1856
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
1855
1857
        self.sock.bind(('127.0.0.1', 0))
1856
1858
        self.sock.listen(1)
1868
1870
    def get_url(self):
1869
1871
        return 'bzr://127.0.0.1:%d/' % (self.port,)
1870
1872
 
1871
 
    def stop_server(self):
 
1873
    def tearDown(self):
1872
1874
        try:
1873
1875
            # make sure the thread dies by connecting to the listening socket,
1874
1876
            # just in case the test failed to do so.
1879
1881
            pass
1880
1882
        self.sock.close()
1881
1883
        self.thread.join()
 
1884