當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。