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 251bf00

Browse filesBrowse files
author
Chris Rossi
authored
test: run asserts involving NDB entities in an NDB context (GoogleCloudPlatform#5713)
When an assert fails, pytest will attempt to do magic to provide meaningful output. When one of the objects in an assert is an NDB entity, this can lead to a `ContextError` if the assert isn't run in an NDB context, which creates a red herring, obscuring the actual failure and sending the developer looking for bugs that aren't there. See GoogleCloudPlatform#5681, GoogleCloudPlatform#5682
1 parent baf65d3 commit 251bf00
Copy full SHA for 251bf00

File tree

Expand file treeCollapse file tree

2 files changed

+5
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+5
-3
lines changed

‎datastore/cloud-ndb/flask_app_test.py

Copy file name to clipboardExpand all lines: datastore/cloud-ndb/flask_app_test.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ def test_index(test_book):
4343
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
4444
def eventually_consistent_test():
4545
r = client.get('/')
46-
assert r.status_code == 200
47-
assert test_book.title in r.data.decode('utf-8')
46+
with flask_app.client.context():
47+
assert r.status_code == 200
48+
assert test_book.title in r.data.decode('utf-8')
4849

4950
eventually_consistent_test()
5051

‎datastore/cloud-ndb/quickstart_test.py

Copy file name to clipboardExpand all lines: datastore/cloud-ndb/quickstart_test.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def test_quickstart(capsys, test_book):
3939
def eventually_consistent_test():
4040
quickstart.list_books()
4141
out, _ = capsys.readouterr()
42-
assert test_book.title in out
42+
with quickstart.client.context():
43+
assert test_book.title in out
4344

4445
eventually_consistent_test()

0 commit comments

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