Falcon v1.2.0 Documentationmodules from unittest.mock if you are using Python 3, or from mock if you are using Python 2. # Python 3 from unittest.mock import mock_open, call # Python 2 from mock import mock_open, call For Python Python 2, you will also need to install the mock package: $ pip install mock Now add the following test: # "monkeypatch" is a special built-in pytest fixture that can be # used to install mocks. def t test_posted_image_gets_saved(client, monkeypatch): mock_file_open = mock_open() monkeypatch.setattr('io.open', mock_file_open) fake_uuid = '123e4567-e89b-12d3-a456-426655440000' monkeypatch0 码力 | 177 页 | 252.56 KB | 1 年前3
Falcon v1.2.0 Documentationmodules from unittest.mock if you are using Python 3, or from mock if you are using Python 2. # Python 3 from unittest.mock import mock_open, call # Python 2 from mock import mock_open, call For Python Python 2, you will also need to install the mock package: 6.2. User Guide 31 Falcon Documentation, Release 1.2.0 $ pip install mock Now add the following test: # "monkeypatch" is a special built-in pytest install mocks. def test_posted_image_gets_saved(client, monkeypatch): mock_file_open = mock_open() monkeypatch.setattr('io.open', mock_file_open) fake_uuid = '123e4567-e89b-12d3-a456-426655440000' monkeypatch0 码力 | 134 页 | 498.46 KB | 1 年前3
Guzzle PHP 5.3 DocumentationDecorators RingPHP Handlers Using a handler Creating a handler Testing Guzzle Clients Mock Subscriber History Subscriber Mock Adapter Test Web Server FAQ Why should I use Guzzle? Does Guzzle require cURL? GuzzleHttp\Subscriber\Mock; use GuzzleHttp\Message\Response; $history = new History(); $mock = new Mock([new Response(200)]); $client->get('/', ['subscribers' => [$history, $mock]]); echo $history; // GuzzleHttp\Ring\Client\MockHandler; // Create a mock handler that always returns a 200 response. $handler = new MockHandler(['status' => 200]); // Configure to client to use the mock handler. $client = new Client(['handler'0 码力 | 72 页 | 312.62 KB | 11 月前3
Falcon v1.3.0 Documentationmodules from unittest.mock if you are using Python 3, or from mock if you are using Python 2. # Python 3 from unittest.mock import mock_open, call # Python 2 from mock import mock_open, call For Python Python 2, you will also need to install the mock package: $ pip install mock Now add the following test: # "monkeypatch" is a special built-in pytest fixture that can be # used to install mocks. def te test_posted_image_gets_saved(client, monkeypatch): mock_file_open = mock_open() monkeypatch.setattr('io.open', mock_file_open) fake_uuid = '123e4567-e89b-12d3-a456-426655440000' monkeypatch.setattr('uuid0 码力 | 146 页 | 535.22 KB | 1 年前3
Falcon v1.3.0 Documentationmodules from unittest.mock if you are using Python 3, or from mock if you are using Python 2. # Python 3 from unittest.mock import mock_open, call # Python 2 from mock import mock_open, call For Python Python 2, you will also need to install the mock package: $ pip install mock Now add the following test: # "monkeypatch" is a special built-in pytest fixture that can be # used to install mocks. def te test_posted_image_gets_saved(client, monkeypatch): mock_file_open = mock_open() monkeypatch.setattr('io.open', mock_file_open) fake_uuid = '123e4567-e89b-12d3-a456-426655440000' monkeypatch0 码力 | 194 页 | 266.90 KB | 1 年前3
Guzzle PHP 5.3 DocumentationGuzzleHttp\Subscriber\Mock; use GuzzleHttp\Message\Response; $history = new History(); $mock = new Mock([new Response(200)]); $client->get('/', ['subscribers' => [$history, $mock]]); echo $history; // GuzzleHttp\Ring\Client\MockHandler; // Create a mock handler that always returns a 200 response. $handler = new MockHandler(['status' => 200]); // Configure to client to use the mock handler. $client = new Client(['handler' enable you to easily mock the HTTP layer without needing to send requests over the internet. • Mock subscriber • Mock handler • Node.js web server for integration testing 1.8.1 Mock Subscriber When testing0 码力 | 63 页 | 275.75 KB | 11 月前3
Falcon v1.4.1 Documentationmodules from unittest.mock if you are using Python 3, or from mock if you are using Python 2. # Python 3 from unittest.mock import mock_open, call # Python 2 from mock import mock_open, call For Python Python 2, you will also need to install the mock package: $ pip install mock Now add the following test: # "monkeypatch" is a special built-in pytest fixture that can be # used to install mocks. def te test_posted_image_gets_saved(client, monkeypatch): mock_file_open = mock_open() monkeypatch.setattr('io.open', mock_file_open) fake_uuid = '123e4567-e89b-12d3-a456-426655440000' monkeypatch.setattr('uuid0 码力 | 158 页 | 587.88 KB | 1 年前3
Falcon v1.4.0 Documentationmodules from unittest.mock if you are using Python 3, or from mock if you are using Python 2. # Python 3 from unittest.mock import mock_open, call # Python 2 from mock import mock_open, call For Python Python 2, you will also need to install the mock package: $ pip install mock Now add the following test: # "monkeypatch" is a special built-in pytest fixture that can be # used to install mocks. def te test_posted_image_gets_saved(client, monkeypatch): mock_file_open = mock_open() monkeypatch.setattr('io.open', mock_file_open) fake_uuid = '123e4567-e89b-12d3-a456-426655440000' monkeypatch.setattr('uuid0 码力 | 156 页 | 573.94 KB | 1 年前3
Falcon v1.4.1 Documentationmodules from unittest.mock if you are using Python 3, or from mock if you are using Python 2. # Python 3 from unittest.mock import mock_open, call # Python 2 from mock import mock_open, call For Python Python 2, you will also need to install the mock package: $ pip install mock Now add the following test: # "monkeypatch" is a special built-in pytest fixture that can be # used to install mocks. def te test_posted_image_gets_saved(client, monkeypatch): mock_file_open = mock_open() monkeypatch.setattr('io.open', mock_file_open) fake_uuid = '123e4567-e89b-12d3-a456-426655440000' monkeypatch.setattr('uuid0 码力 | 156 页 | 574.46 KB | 1 年前3
Falcon v1.4.1-post-1 Documentationmodules from unittest.mock if you are using Python 3, or from mock if you are using Python 2. # Python 3 from unittest.mock import mock_open, call # Python 2 from mock import mock_open, call For Python Python 2, you will also need to install the mock package: $ pip install mock Now add the following test: # "monkeypatch" is a special built-in pytest fixture that can be # used to install mocks. def te test_posted_image_gets_saved(client, monkeypatch): mock_file_open = mock_open() monkeypatch.setattr('io.open', mock_file_open) fake_uuid = '123e4567-e89b-12d3-a456-426655440000' monkeypatch0 码力 | 229 页 | 273.39 KB | 1 年前3
共 59 条
- 1
- 2
- 3
- 4
- 5
- 6













