From: Max Shytikov Date: Sun, 6 Apr 2014 23:08:57 +0000 (+0200) Subject: Added test and impl for Request 'host' attribute X-Git-Tag: v1.0.0~36^2~50 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=18ec57fa73436635eeabd69008c7bd5cfa5e6e13;p=vcrpy.git Added test and impl for Request 'host' attribute --- diff --git a/tests/unit/test_matchers.py b/tests/unit/test_matchers.py index 3bc8846..f06db11 100644 --- a/tests/unit/test_matchers.py +++ b/tests/unit/test_matchers.py @@ -37,5 +37,6 @@ def test_url_matcher(): def test_metchers(): assert_matcher('method') + assert_matcher('host') #assert_matcher('method') #assert_matcher('method') diff --git a/vcr/request.py b/vcr/request.py index a224225..7debabf 100644 --- a/vcr/request.py +++ b/vcr/request.py @@ -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