Skip to content

Commit eceaae2

Browse files
committed
Clean up httplib tests.
1 parent cf9f93d commit eceaae2

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

tests/ext/httplib/test_httplib.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def construct_ctx():
2525
so that later subsegment can be attached. After each test run
2626
it cleans up context storage again.
2727
"""
28-
from aws_xray_sdk.ext.httplib import unpatch
28+
from aws_xray_sdk.ext.httplib import unpatch, reset_ignored
2929

3030
patch(('httplib',))
3131
xray_recorder.configure(service='test', sampling=False, context=Context())
@@ -35,6 +35,7 @@ def construct_ctx():
3535
yield
3636
xray_recorder.clear_trace_entities()
3737
unpatch()
38+
reset_ignored()
3839

3940

4041
def _do_req(url, method='GET', use_https=True):
@@ -144,62 +145,61 @@ def test_correct_identify_https():
144145

145146

146147
def test_ignore_url():
147-
from aws_xray_sdk.ext.httplib import add_ignored, reset_ignored
148+
from aws_xray_sdk.ext.httplib import add_ignored
148149
path = '/status/200'
149150
url = 'https://{}{}'.format(BASE_URL, path)
150151
add_ignored(urls=[path])
151152
_do_req(url, use_https=True)
152153
assert len(xray_recorder.current_segment().subsegments) == 0
153-
reset_ignored()
154154

155155

156156
def test_ignore_hostname():
157-
from aws_xray_sdk.ext.httplib import add_ignored, reset_ignored
157+
from aws_xray_sdk.ext.httplib import add_ignored
158158
path = '/status/200'
159159
url = 'https://{}{}'.format(BASE_URL, path)
160160
add_ignored(hostname=BASE_URL)
161161
_do_req(url, use_https=True)
162162
assert len(xray_recorder.current_segment().subsegments) == 0
163-
reset_ignored()
164163

165164

166165
def test_ignore_hostname_glob():
167-
from aws_xray_sdk.ext.httplib import add_ignored, reset_ignored
166+
from aws_xray_sdk.ext.httplib import add_ignored
168167
path = '/status/200'
169168
url = 'https://{}{}'.format(BASE_URL, path)
170169
add_ignored(hostname='http*.org')
171170
_do_req(url, use_https=True)
172171
assert len(xray_recorder.current_segment().subsegments) == 0
173-
reset_ignored()
172+
173+
174+
class TestClass(httplib.HTTPSConnection):
175+
pass
174176

175177

176178
def test_ignore_subclass():
177-
class TestClass(httplib.HTTPSConnection):
178-
pass
179-
from aws_xray_sdk.ext.httplib import add_ignored, reset_ignored
179+
from aws_xray_sdk.ext.httplib import add_ignored
180180
path = '/status/200'
181181
add_ignored(subclass='TestClass')
182182
conn = TestClass(BASE_URL)
183183
conn.request('GET', path)
184184
conn.getresponse()
185185
assert len(xray_recorder.current_segment().subsegments) == 0
186-
reset_ignored()
187186

188187

189-
def test_ignore_multiple():
190-
class TestClass(httplib.HTTPSConnection):
191-
pass
192-
from aws_xray_sdk.ext.httplib import add_ignored, reset_ignored
188+
def test_ignore_multiple_match():
189+
from aws_xray_sdk.ext.httplib import add_ignored
193190
path = '/status/200'
194191
add_ignored(subclass='TestClass', hostname=BASE_URL)
195192
conn = TestClass(BASE_URL)
196193
conn.request('GET', path)
197194
conn.getresponse()
198195
assert len(xray_recorder.current_segment().subsegments) == 0
199-
reset_ignored()
196+
197+
198+
def test_ignore_multiple_no_match():
199+
from aws_xray_sdk.ext.httplib import add_ignored
200+
path = '/status/200'
200201
add_ignored(subclass='TestClass', hostname='fake.host')
201202
conn = TestClass(BASE_URL)
202203
conn.request('GET', path)
203204
conn.getresponse()
204205
assert len(xray_recorder.current_segment().subsegments) > 0
205-
reset_ignored()

0 commit comments

Comments
 (0)