From 18ec57fa73436635eeabd69008c7bd5cfa5e6e13 Mon Sep 17 00:00:00 2001 From: Max Shytikov Date: Mon, 7 Apr 2014 01:08:57 +0200 Subject: [PATCH] Added test and impl for Request 'host' attribute --- tests/unit/test_matchers.py | 1 + vcr/request.py | 7 +++++++ 2 files changed, 8 insertions(+) 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