~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/HTTPTestUtil.py

  • Committer: Martin Pool
  • Date: 2006-02-22 04:29:54 UTC
  • mfrom: (1566 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1569.
  • Revision ID: mbp@sourcefrog.net-20060222042954-60333f08dd56a646
[merge] from bzr.dev before integration
Fix undefined ordering in sign_my_revisions breaking tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import os
18
18
 
19
 
 
20
 
from bzrlib.tests import TestCaseInTempDir
21
 
from bzrlib.transport.http import HttpServer
22
 
from bzrlib.osutils import relpath
23
 
 
24
 
 
25
 
class TestCaseWithWebserver(TestCaseInTempDir):
26
 
    """Derived class that starts a localhost-only webserver.
27
 
    (in addition to what TestCaseInTempDir does).
28
 
 
29
 
    This is useful for testing things with a web server.
 
19
import bzrlib
 
20
from bzrlib.tests import TestCaseWithTransport
 
21
 
 
22
 
 
23
class TestCaseWithWebserver(TestCaseWithTransport):
 
24
    """A support class that provides readonly urls that are http://.
 
25
 
 
26
    This is done by forcing the readonly server to be an http one. This 
 
27
    will current fail if the primary transport is not backed by regular disk
 
28
    files.
30
29
    """
31
30
 
32
 
    def get_remote_url(self, path):
33
 
 
34
 
        if os.path.isabs(path):
35
 
            remote_path = relpath(self.test_dir, path)
36
 
        else:
37
 
            remote_path = path
38
 
        return self.server.get_url() + remote_path
39
 
 
40
31
    def setUp(self):
41
32
        super(TestCaseWithWebserver, self).setUp()
42
 
        self.server = HttpServer()
43
 
        self.server.setUp()
44
 
        self.addCleanup(self.server.tearDown)
 
33
        self.transport_readonly_server = bzrlib.transport.http.HttpServer