本文整理汇总了Python中responses.stop方法的典型用法代码示例。如果您正苦于以下问题:Python responses.stop方法的具体用法?Python responses.stop怎么用?Python responses.stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类responses
的用法示例。
在下文中一共展示了responses.stop方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mock_request
# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def mock_request():
with open(path.join(path.dirname(path.realpath(__file__)),
'fake_response.json')) as f:
fake_response = json.load(f)
responses.add(
responses.GET,
url=("https://www.bing.com/HPImageArchive.aspx?format"
"=js&idx=0&n=1&nc=1409879295618&pid=hp"),
json=fake_response,
status=200,
match_querystring=True
)
responses.add(
responses.GET,
url=('https://www.bing.com/th?id=OHR.OldManWhiskers_ZH-CN9321160932_'
'1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp'),
status=200,
body='Hello, world'
)
responses.start()
yield responses
responses.stop()
示例2: pytest_runtest_teardown
# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def pytest_runtest_teardown(item):
if not get_withoutresponses_marker(item):
try:
responses_.stop()
responses_.reset()
except RuntimeError:
# patcher was already uninstalled and responses doesnt let us
# force maintain it
pass
示例3: mock_api
# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def mock_api():
with open(path.join(ROOT, 'signin.html'), encoding='utf-8') as f:
mock_signin_body = f.read()
responses.add(responses.POST, 'https://www.v2ex.com/signin',
body=mock_signin_body)
responses.add(responses.GET, 'https://www.v2ex.com/signin',
body=mock_signin_body)
with open(path.join(ROOT, 'once.html'), encoding='utf-8') as f:
mock_once_body = f.read()
responses.add(responses.GET,
'https://www.v2ex.com/mission/daily/redeem?once=51947',
body=mock_once_body)
with open(path.join(ROOT, 'balance.html'), encoding='utf-8') as f:
mock_balance_body = f.read()
responses.add(responses.GET, 'https://www.v2ex.com/balance',
body=mock_balance_body)
with open(path.join(ROOT, 'mission.html'), encoding='utf-8') as f:
mock_mission_body = f.read()
responses.add(responses.GET, 'https://www.v2ex.com/mission/daily',
body=mock_mission_body)
responses.start()
yield responses
responses.stop()
示例4: response_fixture_factory
# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def response_fixture_factory(url, data=None, status=200):
@pytest.yield_fixture
def fixture():
responses.add(
responses.POST,
url,
status=status,
body=json.dumps(data or {}),
content_type='application/json',
)
responses.start()
yield responses
responses.stop()
responses.reset()
return fixture
示例5: tearDown
# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def tearDown(self):
await super(HollowmanAppTest, self).tearDown()
responses.stop()
示例6: tearDown
# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def tearDown(self):
await super(AuthenticationTest, self).tearDown()
responses.stop()
示例7: tearDown
# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def tearDown(self):
responses.stop()
示例8: tearDown
# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def tearDown(self):
responses.stop()
# todo: debater nome request_app e app <- app fica ambíguo
示例9: tearDown
# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def tearDown(self):
self.mock.stop()
responses.stop()
super(AddVersionedListsTest, self).tearDown()
示例10: teardown_method
# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def teardown_method(self, method):
responses.reset()
responses.stop()