Skip to content

Commit

Permalink
Remove some blockers for Python3.8 support. (#516)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonathanmetzman authored Jul 13, 2020
1 parent 252fb5d commit 60eee49
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion experiment/build/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import itertools
import os
import sys
from unittest import mock

import pytest
Expand Down Expand Up @@ -62,7 +63,8 @@ def get_benchmarks_or_fuzzers(benchmarks_or_fuzzers_directory, filename,
]


# This test seems to hang on Python3.8+
@pytest.mark.skipif(sys.version_info.minor > 7,
reason='Test can hang on versions greater than 3.7')
@mock.patch('experiment.build.builder.build_measurer')
@mock.patch('time.sleep')
@pytest.mark.parametrize('build_measurer_return_value', [True, False])
Expand Down
2 changes: 1 addition & 1 deletion experiment/test_run_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def test_validate_experiment_name_invalid(experiment_name):


# This test takes up to a minute to complete.
@pytest.mark.long
@pytest.mark.slow
def test_copy_resources_to_bucket(tmp_path):
"""Tests that copy_resources_to_bucket copies the correct resources."""
# Do this so that Ctrl-C doesn't pollute the repo.
Expand Down
9 changes: 9 additions & 0 deletions presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ def lint(paths: List[Path]) -> bool:
def pytype(paths: List[Path]) -> bool:
"""Run pytype on |path| if it is a python file. Return False if it fails
type checking."""
# Pytype isn't supported on Python3.8+. See
# https://github.com/google/pytype/issues/440.
assert sys.version_info.major == 3, "Need Python3."
if sys.version_info.minor > 7:
logs.error(
'Python version is: "%s". You should be using 3.7. '
'Not running pytype.', sys.version)
return True

paths = [path for path in paths if is_python(path)]
if not paths:
return True
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[pytest]
norecursedirs = docs/_site/* docs/vendor/* third_party/* .venv/*

markers =
slow: marks tests as slow (deselect with '-m "not slow"')

0 comments on commit 60eee49

Please sign in to comment.