コード例 #1
0
    def __getitem__(self, item):
        if item != 'Location':
            raise TypeError('Keys other than "Location" are unsupported')

        # django's test response returns location as http://testserver/,
        # WebTest returns it as http://localhost:80/
        e_scheme, e_netloc, e_path, e_query, e_fragment = urlparse.urlsplit(self.location)
        if e_netloc == 'localhost:80':
            e_netloc = 'testserver'
        return urlparse.urlunsplit([e_scheme, e_netloc, e_path, e_query, e_fragment])
コード例 #2
0
ファイル: response.py プロジェクト: carljm/django-webtest
 def __getitem__(self, item):
     item = item.lower()
     if item == 'location':
         # django's test response returns location as http://testserver/,
         # WebTest returns it as http://localhost:80/
         e_scheme, e_netloc, e_path, e_query, e_fragment = urlparse.urlsplit(self.location)
         if e_netloc == 'localhost:80':
             e_netloc = 'testserver'
         return urlparse.urlunsplit([e_scheme, e_netloc, e_path, e_query, e_fragment])
     for header, value in self.headerlist:
         if header.lower() == item:
             return value
     raise KeyError(item)
コード例 #3
0
 def __getitem__(self, item):
     item = item.lower()
     if item == 'location':
         # django's test response returns location as http://testserver/,
         # WebTest returns it as http://localhost:80/
         e_scheme, e_netloc, e_path, e_query, e_fragment = urlparse.urlsplit(self.location)
         if e_netloc == 'localhost:80':
             e_netloc = 'testserver'
         return urlparse.urlunsplit([e_scheme, e_netloc, e_path, e_query, e_fragment])
     for header, value in self.headerlist:
         if header.lower() == item:
             return value
     raise KeyError(item)