Skip to content

chore(gae): POC - enable support for tests on Python 3 #13242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions appengine/standard/analytics/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# pin pytest to 4.6.11 for Python2.
pytest==4.6.11; python_version < '3.0'
responses==0.17.0; python_version < '3.7'
#pytest==4.6.11; python_version < '3.0'
#responses==0.17.0; python_version < '3.7'
responses==0.23.1; python_version > '3.6'

responses==0.23.1
pytest==8.3.5
six==1.17.0
15 changes: 10 additions & 5 deletions appengine/standard/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@
(testbed)


def pytest_ignore_collect(path, config):
"""Skip App Engine tests in python 3 or if no SDK is available."""
if "appengine/standard" in str(path):
if six.PY3:
return True
def pytest_ignore_collect(collection_path):
"""Skip App Engine tests if no SDK is available."""
if "appengine/standard" in str(collection_path):
if "GAE_SDK_PATH" not in os.environ:
#test_file = os.path.basename(collection_path)
test_file = os.path.join(collection_path.parent.name, collection_path.name)

if ".py" in test_file:
print("GAE_SDK_PATH is missing! "
f"Skipping App Engine test in {test_file}."
)
Comment on lines +42 to +44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error message could be improved to provide more guidance to the user. Consider suggesting how to set the GAE_SDK_PATH environment variable or where to find the SDK.

Suggested change
print("GAE_SDK_PATH is missing! "
f"Skipping App Engine test in {test_file}."
)
print("GAE_SDK_PATH is missing! "
f"Skipping App Engine test in {test_file}. "
"Please set the GAE_SDK_PATH environment variable to the location of the App Engine SDK.")

return True
Comment on lines 37 to 45
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The original code had a check for six.PY3 to skip tests on Python 3. This check is now removed. It would be helpful to add a comment explaining why this check is no longer needed or how the current logic handles Python 3 differently. Otherwise, it's not clear if this change is intentional or not, and what the implications are.

Suggested change
if "GAE_SDK_PATH" not in os.environ:
#test_file = os.path.basename(collection_path)
test_file = os.path.join(collection_path.parent.name, collection_path.name)
if ".py" in test_file:
print("GAE_SDK_PATH is missing! "
f"Skipping App Engine test in {test_file}."
)
return True
if "GAE_SDK_PATH" not in os.environ:
# The six.PY3 check was removed because ...
test_file = os.path.join(collection_path.parent.name, collection_path.name)
if ".py" in test_file:
print("GAE_SDK_PATH is missing! "
f"Skipping App Engine test in {test_file}."
)
return True

return False
2 changes: 2 additions & 0 deletions appengine/standard/hello_world/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest==8.3.5
six==1.17.0
Empty file.