当前位置: 首页>>代码示例>>Python>>正文


Python responses.stop方法代码示例

本文整理汇总了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() 
开发者ID:lord63,项目名称:wonderful_bing,代码行数:26,代码来源:conftest.py

示例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 
开发者ID:getsentry,项目名称:pytest-responses,代码行数:11,代码来源:pytest_responses.py

示例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() 
开发者ID:lord63,项目名称:v2ex_daily_mission,代码行数:30,代码来源:conftest.py

示例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 
开发者ID:jmcarp,项目名称:betfair.py,代码行数:17,代码来源:utils.py

示例5: tearDown

# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def tearDown(self):
        await super(HollowmanAppTest, self).tearDown()
        responses.stop() 
开发者ID:b2wdigital,项目名称:asgard-api,代码行数:5,代码来源:test_hollowman_app.py

示例6: tearDown

# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def tearDown(self):
        await super(AuthenticationTest, self).tearDown()
        responses.stop() 
开发者ID:b2wdigital,项目名称:asgard-api,代码行数:5,代码来源:test_auth.py

示例7: tearDown

# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def tearDown(self):
        responses.stop() 
开发者ID:b2wdigital,项目名称:asgard-api,代码行数:4,代码来源:test_request_pipeline.py

示例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 
开发者ID:b2wdigital,项目名称:asgard-api,代码行数:6,代码来源:test_request.py

示例9: tearDown

# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def tearDown(self):
        self.mock.stop()
        responses.stop()
        super(AddVersionedListsTest, self).tearDown() 
开发者ID:mozilla-services,项目名称:shavar,代码行数:6,代码来源:test_lists.py

示例10: teardown_method

# 需要导入模块: import responses [as 别名]
# 或者: from responses import stop [as 别名]
def teardown_method(self, method):
        responses.reset()
        responses.stop() 
开发者ID:joaobarbosa,项目名称:onesignal-python,代码行数:5,代码来源:base_test.py


注:本文中的responses.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。