Skip to content

Commit

Permalink
chore: drop mention of Python 2.7 from templates (#1173)
Browse files Browse the repository at this point in the history
Install async test dependencies unconditionally.

Drop unused 'samples' session. Samples are tested via separate noxfiles in all repos which have them.

Closes #1118.

Co-authored-by: Anthonios Partheniou <[email protected]>
  • Loading branch information
tseaver and parthea authored Aug 13, 2021
1 parent ff01716 commit facee4c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 33 deletions.
8 changes: 0 additions & 8 deletions synthtool/gcp/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,17 +225,9 @@ def py_library(self, **kwargs) -> Path:
kwargs["default_python_version"] = "3.8"
if "unit_test_python_versions" not in kwargs:
kwargs["unit_test_python_versions"] = ["3.6", "3.7", "3.8", "3.9"]
if "microgenerator" not in kwargs:
kwargs["unit_test_python_versions"] = ["2.7"] + kwargs[
"unit_test_python_versions"
]

if "system_test_python_versions" not in kwargs:
kwargs["system_test_python_versions"] = ["3.8"]
if "microgenerator" not in kwargs:
kwargs["system_test_python_versions"] = ["2.7"] + kwargs[
"system_test_python_versions"
]

# If cov_level is not given, set it to None.
if "cov_level" not in kwargs:
Expand Down
20 changes: 2 additions & 18 deletions synthtool/gcp/templates/python_library/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ def default(session):
constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
{%- if microgenerator %}
session.install("asyncmock", "pytest-asyncio", "-c", constraints_path)
{% endif %}
session.install("mock", "pytest", "pytest-cov", {% for d in unit_test_external_dependencies %}"{{d}}",{% endfor %} "-c", constraints_path)
session.install("mock", "asyncmock", "pytest", "pytest-cov", "pytest-asyncio", "-c", constraints_path)
{% for d in unit_test_external_dependencies %}session.install("{{d}}", "-c", constraints_path){% endfor %}
{% for dependency in unit_test_local_dependencies %}session.install("-e", "{{dependency}}", "-c", constraints_path)
{% endfor %}
{% for dependency in unit_test_dependencies %}session.install("-e", "{{dependency}}", "-c", constraints_path){% endfor %}
Expand Down Expand Up @@ -192,20 +190,6 @@ def system(session):
*session.posargs
)

{% if samples_test %}
@nox.session(python=["2.7", "3.7"])
def samples(session):
requirements_path = os.path.join("samples", "requirements.txt")
requirements_exists = os.path.exists(requirements_path)

session.install("mock", "pytest")
if requirements_exists:
session.install("-r", requirements_path)
session.install("-e", ".")

session.run("py.test", "--quiet", "samples", *session.posargs)
{% endif %}

@nox.session(python=DEFAULT_PYTHON_VERSION)
def cover(session):
"""Run the final coverage report.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Install Dependencies
.. _Python Development Environment Setup Guide:
https://cloud.google.com/python/setup

#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
#. Create a virtualenv. Samples are compatible with Python 3.6+.

.. code-block:: bash
Expand Down
6 changes: 3 additions & 3 deletions synthtool/gcp/templates/python_samples/noxfile.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ BLACK_VERSION = "black==19.10b0"

TEST_CONFIG = {
# You can opt out from the test for specific Python versions.
'ignored_versions': ["2.7"],
'ignored_versions': [],

# Old samples are opted out of enforcing Python type hints
# All new samples should feature them
Expand Down Expand Up @@ -88,8 +88,8 @@ def get_pytest_env_vars() -> Dict[str, str]:


# DO NOT EDIT - automatically generated.
# All versions used to tested samples.
ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"]
# All versions used to test samples.
ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]

# Any default versions that should be ignored.
IGNORED_VERSIONS = TEST_CONFIG['ignored_versions']
Expand Down
6 changes: 3 additions & 3 deletions synthtool/languages/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import re
import sys
from pathlib import Path
from typing import Any, Dict
from typing import Any, Dict, List

import yaml

Expand Down Expand Up @@ -45,8 +45,8 @@
# See the License for the specific language governing permissions and
# limitations under the License."""

SAMPLES_VERSIONS = ["2.7", "3.6", "3.7", "3.8"]
IGNORED_VERSIONS = ["2.7"]
SAMPLES_VERSIONS = ["3.6", "3.7", "3.8"]
IGNORED_VERSIONS: List[str] = []

SAMPLES_TEMPLATE_PATH = Path(CommonTemplates()._template_root) / "python_samples"

Expand Down

0 comments on commit facee4c

Please sign in to comment.