* Bump to python 3.8

* Avoid RuntimeError: dictionary keys changed during iteration

* Fix hanging test_tracker_updates_records_with_missing_data

* Disable pytest warning on on Unraisable exceptions
This commit is contained in:
Bastien Abadie 2022-05-16 20:30:31 +02:00 коммит произвёл GitHub
Родитель 50297491c3
Коммит 68596acba4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 23 добавлений и 24 удалений

Просмотреть файл

@ -24,7 +24,7 @@ jobs:
builds:
docker:
- image: 'circleci/python:3.7-node'
- image: 'circleci/python:3.8-node'
steps:
- checkout
- restore_cache:

Просмотреть файл

@ -20,4 +20,4 @@ repos:
rev: 22.3.0
hooks:
- id: black
language_version: python3.7
language_version: python3.8

Просмотреть файл

@ -12,7 +12,7 @@ RUN yarn build
## Backend stage
FROM python:3.7.12-slim
FROM python:3.8.13-slim
# libmysqlclient-dev is required for the mysqlclient Python package.
RUN apt-get update && apt-get install -y --no-install-recommends \

Просмотреть файл

@ -1,4 +1,4 @@
FROM python:3.7.12
FROM python:3.8.13
# Variables that are not specific to a particular environment.
ENV NEW_RELIC_CONFIG_FILE newrelic.ini

Просмотреть файл

@ -9,7 +9,7 @@ description = "This is the package installer for docs"
authors = ["Mozilla"]
[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"
# A list of all of the optional dependencies, some of which are included in the
# below `extras`. They can be opted into by apps.
@ -22,7 +22,7 @@ docs = ["mkdocs", "mkdocs-material", "mdx_truly_sane_lists"]
[tool.black]
line-length = 100
target-version = ['py37']
target-version = ['py38']
skip-string-normalization = true
include = '\.pyi?$'
exclude = '''
@ -31,4 +31,4 @@ exclude = '''
| treeherder/perf/migrations
| treeherder/changelog/migrations
)/
'''
'''

Просмотреть файл

@ -16,7 +16,7 @@ DJANGO_SETTINGS_MODULE=tests.settings
addopts = -rsx -p no:mozlog
# Make most warnings fatal (including the hidden by default DeprecationWarning):
# https://docs.pytest.org/en/latest/warnings.html
# https://docs.python.org/3.7/library/warnings.html#warning-categories
# https://docs.python.org/3.8/library/warnings.html#warning-categories
filterwarnings =
error
ignore::ImportWarning

Просмотреть файл

@ -265,7 +265,7 @@ def test_tracker_lets_web_service_rest(mock_formula_map, updatable_criteria_csv)
tracker.update_records()
@pytest.mark.freeze_time(CASSETTES_RECORDING_DATE) # disable tick
# We cannot use freeze_time here as it breaks the multiprocessing & sleep usages in CriteriaTracker
def test_tracker_updates_records_with_missing_data(mock_formula_map, updatable_criteria_csv):
# all tests from the fixture don't have any kind of data
tracker = CriteriaTracker(
@ -295,7 +295,8 @@ def test_tracker_updates_records_with_missing_data(mock_formula_map, updatable_c
assert criteria_rec.EngineerTraction == EXPECTED_VALUE
assert criteria_rec.FixRatio == EXPECTED_VALUE
assert criteria_rec.TotalAlerts == 0
assert criteria_rec.LastUpdatedOn == EXPECTED_LAST_UPDATE
# We cannot compare exactly as the freeze_time method is not usable here
assert criteria_rec.LastUpdatedOn > EXPECTED_LAST_UPDATE
assert criteria_rec.AllowSync is True

Просмотреть файл

@ -1,5 +1,5 @@
[tox]
envlist = py37
envlist = py38
isolated_build = true
skipsdist=True
@ -46,7 +46,7 @@ whitelist_externals=
commands_pre =
docker-compose build
commands =
docker-compose run -e TREEHERDER_DEBUG=False backend bash -c "pytest --cov --cov-report=xml tests/ --runslow"
docker-compose run -e TREEHERDER_DEBUG=False backend bash -c "pytest --cov --cov-report=xml tests/ --runslow -p no:unraisableexception"
[flake8]
per-file-ignores = treeherder/model/models.py:E402

Просмотреть файл

@ -315,33 +315,31 @@ class JobsProjectViewSet(viewsets.ViewSet):
"""
MAX_JOBS_COUNT = 2000
# make a mutable copy of these params
filter_params = request.query_params.copy()
filter_params = {}
# various hacks to ensure API backwards compatibility
for param_key in filter_params.keys():
for param_key, param_value in request.query_params.items():
# replace `result_set_id` with `push_id`
if param_key.startswith('result_set_id'):
new_param_key = param_key.replace('result_set_id', 'push_id')
filter_params[new_param_key] = filter_params[param_key]
del filter_params[param_key]
filter_params[new_param_key] = param_value
# convert legacy timestamp parameters to time ones
elif param_key in ['submit_timestamp', 'start_timestamp', 'end_timestamp']:
new_param_key = param_key.replace('timestamp', 'time')
filter_params[new_param_key] = datetime.datetime.fromtimestamp(
float(filter_params[param_key])
)
del filter_params[param_key]
filter_params[new_param_key] = datetime.datetime.fromtimestamp(float(param_value))
# sanity check 'last modified'
elif param_key.startswith('last_modified'):
datestr = filter_params[param_key]
try:
parser.parse(datestr)
parser.parse(param_value)
except ValueError:
return Response(
"Invalid date value for `last_modified`: {}".format(datestr),
"Invalid date value for `last_modified`: {}".format(param_value),
status=HTTP_400_BAD_REQUEST,
)
filter_params[param_key] = param_value
# default case
else:
filter_params[param_key] = param_value
try:
offset = int(filter_params.get("offset", 0))