/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
452
452
        # Import the module locally now that we now it's available.
453
453
        pycurl = features.pycurl.module
454
454
 
455
 
        version_info_orig = pycurl.version_info
456
 
        def restore():
457
 
            pycurl.version_info = version_info_orig
458
 
        self.addCleanup(restore)
459
 
 
 
455
        self.addAttrCleanup(pycurl, 'version_info')
460
456
        # Fake the pycurl version_info This was taken from a windows pycurl
461
457
        # without SSL (thanks to bialix)
462
458
        pycurl.version_info = lambda : (2,
1364
1360
 
1365
1361
 
1366
1362
def install_redirected_request(test):
1367
 
    test.original_class = _urllib2_wrappers.Request
1368
 
    def restore():
1369
 
        _urllib2_wrappers.Request = test.original_class
 
1363
    test.addAttrCleanup(_urllib2_wrappers, 'Request')
1370
1364
    _urllib2_wrappers.Request = RedirectedRequest
1371
 
    test.addCleanup(restore)
1372
1365
 
1373
1366
 
1374
1367
class TestHTTPSilentRedirections(http_utils.TestCaseWithRedirectedWebserver):