MCPcopy Create free account
hub / github.com/ipython/ipython / mocked_urlopen

Function mocked_urlopen

IPython/core/tests/test_display.py:86–101  ·  view source on GitHub ↗
(*args, **kwargs)

Source from the content-addressed store, hash-verified

84 gzip_svg = gzip_svg.getvalue()
85
86 def mocked_urlopen(*args, **kwargs):
87 class MockResponse:
88 def __init__(self, svg):
89 self._svg_data = svg
90 self.headers = {'content-type': 'image/svg+xml'}
91
92 def read(self):
93 return self._svg_data
94
95 if args[0] == url:
96 return MockResponse(svg_data)
97 elif args[0] == url + 'z':
98 ret= MockResponse(gzip_svg)
99 ret.headers['content-encoding']= 'gzip'
100 return ret
101 return MockResponse(None)
102
103 with mock.patch('urllib.request.urlopen', side_effect=mocked_urlopen):
104 svg = display.SVG(url=url)

Callers

nothing calls this directly

Calls 1

MockResponseClass · 0.85

Tested by

no test coverage detected