]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Added test and impl for Request 'host' attribute
authorMax Shytikov <mshytikov@gmail.com>
Sun, 6 Apr 2014 23:08:57 +0000 (01:08 +0200)
committerMax Shytikov <mshytikov@gmail.com>
Wed, 30 Apr 2014 00:27:52 +0000 (02:27 +0200)
tests/unit/test_matchers.py
vcr/request.py

index 3bc8846ca41af7a0b02a228cd6ab10129c89ccbd..f06db11f30927a3b10d0501711c4c27c15265519 100644 (file)
@@ -37,5 +37,6 @@ def test_url_matcher():
 
 def test_metchers():
     assert_matcher('method')
+    assert_matcher('host')
     #assert_matcher('method')
     #assert_matcher('method')
index a224225758bb7014bff7dae8103cd09c1c485f21..7debabf620608d121f7febf061cc4983b150b049 100644 (file)
@@ -1,3 +1,6 @@
+from six.moves.urllib.parse import urlparse, parse_qsl
+
+
 class Request(object):
 
     def __init__(self, method, uri, body, headers):
@@ -12,6 +15,10 @@ class Request(object):
         tmp[key] = value
         self.headers = frozenset(tmp.iteritems())
 
+    @property
+    def host(self):
+        return urlparse(self.uri).hostname
+
     @property
     def url(self):
         return self.uri