Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 19788b0

Browse filesBrowse files
authored
Convert tasks example to use logging for testability (GoogleCloudPlatform#1219)
* Convert tasks example to use logging for testability * Use capsys to test tasks
1 parent 6f0f4f9 commit 19788b0
Copy full SHA for 19788b0

File tree

Expand file treeCollapse file tree

1 file changed

+7
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-8
lines changed

‎appengine/flexible/tasks/main_test.py

Copy file name to clipboardExpand all lines: appengine/flexible/tasks/main_test.py
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import mock
1615
import pytest
1716

1817

@@ -28,19 +27,19 @@ def test_index(app):
2827
assert r.status_code == 200
2928

3029

31-
@mock.patch('logging.warn')
32-
def test_log_payload(logging_mock, app):
33-
payload = 'hello'
30+
def test_log_payload(capsys, app):
31+
payload = 'test_payload'
3432

3533
r = app.post('/log_payload', data=payload)
3634
assert r.status_code == 200
3735

38-
assert logging_mock.called
36+
out, _ = capsys.readouterr()
37+
assert payload in out
3938

4039

41-
@mock.patch('logging.warn')
42-
def test_empty_payload(logging_mock, app):
40+
def test_empty_payload(capsys, app):
4341
r = app.post('/log_payload')
4442
assert r.status_code == 200
4543

46-
assert logging_mock.called
44+
out, _ = capsys.readouterr()
45+
assert 'empty payload' in out

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.