Skip to content

Commit 60eee49

Browse files
Remove some blockers for Python3.8 support. (google#516)
Remove some blockers for Python3.8 support. 1. Only use pytype on 3.7 since it doesn't work on 3.8+ 2. Skip a test that hangs if not on Python3.7. Also, mark a test as "slow" instead of "long" and register the marker to avoid getting the warnings.
1 parent 252fb5d commit 60eee49

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

experiment/build/test_builder.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import itertools
1717
import os
18+
import sys
1819
from unittest import mock
1920

2021
import pytest
@@ -62,7 +63,8 @@ def get_benchmarks_or_fuzzers(benchmarks_or_fuzzers_directory, filename,
6263
]
6364

6465

65-
# This test seems to hang on Python3.8+
66+
@pytest.mark.skipif(sys.version_info.minor > 7,
67+
reason='Test can hang on versions greater than 3.7')
6668
@mock.patch('experiment.build.builder.build_measurer')
6769
@mock.patch('time.sleep')
6870
@pytest.mark.parametrize('build_measurer_return_value', [True, False])

experiment/test_run_experiment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def test_validate_experiment_name_invalid(experiment_name):
226226

227227

228228
# This test takes up to a minute to complete.
229-
@pytest.mark.long
229+
@pytest.mark.slow
230230
def test_copy_resources_to_bucket(tmp_path):
231231
"""Tests that copy_resources_to_bucket copies the correct resources."""
232232
# Do this so that Ctrl-C doesn't pollute the repo.

presubmit.py

+9
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ def lint(paths: List[Path]) -> bool:
210210
def pytype(paths: List[Path]) -> bool:
211211
"""Run pytype on |path| if it is a python file. Return False if it fails
212212
type checking."""
213+
# Pytype isn't supported on Python3.8+. See
214+
# https://github.com/google/pytype/issues/440.
215+
assert sys.version_info.major == 3, "Need Python3."
216+
if sys.version_info.minor > 7:
217+
logs.error(
218+
'Python version is: "%s". You should be using 3.7. '
219+
'Not running pytype.', sys.version)
220+
return True
221+
213222
paths = [path for path in paths if is_python(path)]
214223
if not paths:
215224
return True

pytest.ini

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[pytest]
22
norecursedirs = docs/_site/* docs/vendor/* third_party/* .venv/*
3+
4+
markers =
5+
slow: marks tests as slow (deselect with '-m "not slow"')

0 commit comments

Comments
 (0)