diff --git a/.travis.yml b/.travis.yml index 5440eb87e..326669a03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -71,9 +71,9 @@ matrix: # https://docs.python.org/2/using/cmdline.html#cmdoption-3 - python -3 -m pytest tests/selenium/ --driver Firefox - - env: python3-smoketest + - env: python3-main language: python - python: '3.6.5' + python: '3.7.2' cache: directories: - ${HOME}/venv @@ -83,11 +83,27 @@ matrix: - mysql -u root -e 'create database test_treeherder;' script: - pip check + - python lints/queuelint.py - flake8 --show-source + - isort --check-only --diff --quiet - SITE_URL='https://treeherder.dev' TREEHERDER_DEBUG='False' ./manage.py check --deploy --fail-level WARNING - # Remove these once we get the roughly equivalent pytest sanity tests working under Python 3. - - ./manage.py migrate - - ./manage.py makemigrations --check + - pytest tests/ --runslow --ignore=tests/selenium/ + + - env: python3-tests-selenium + language: python + python: '3.7.2' + cache: + directories: + - ${HOME}/venv + - node_modules + install: + - nvm install 11 + - source ./bin/travis-setup.sh services python_env geckodriver js_env + before_script: + # Run in `before_script` to prevent the selenium tests from still being run if the UI build fails. + - yarn build + script: + - pytest tests/selenium/ --driver Firefox notifications: email: diff --git a/tests/auth/test_backends.py b/tests/auth/test_backends.py index 4f2398141..5710d113b 100644 --- a/tests/auth/test_backends.py +++ b/tests/auth/test_backends.py @@ -5,6 +5,7 @@ import pytest from django.conf import settings from django.contrib.auth.models import User from django.urls import reverse +from six import PY3 from treeherder.auth.backends import (AuthBackend, AuthenticationFailed) @@ -35,16 +36,17 @@ def test_get_username_from_userinfo(user_info, exp_username, exp_exception): @pytest.mark.django_db @pytest.mark.parametrize( ('exp_username', 'email', 'exp_create_user'), - [('email/user@foo.com', - 'user@foo.com', - True), - ('email/emailaddressexceeding30chars@foo.com', - 'emailaddressexceeding30chars@foo.com', - True), - ('email/foo@bar.net', - 'foo@bar.net', - False), - ]) + [ + ('email/user@foo.com', 'user@foo.com', True), + ('email/emailaddressexceeding30chars@foo.com', 'emailaddressexceeding30chars@foo.com', True), + pytest.param( + 'email/foo@bar.net', 'foo@bar.net', False, + marks=pytest.mark.xfail( + PY3, reason='Python 3: < not supported between instances of str and int (bug 1453837)' + ) + ), + ] +) def test_existing_email_create_user(test_user, client, monkeypatch, exp_username, email, exp_create_user): """ Test whether a user was created or not, despite an existing user with diff --git a/tests/e2e/test_job_ingestion.py b/tests/e2e/test_job_ingestion.py index d52ba1e50..251bd9c82 100644 --- a/tests/e2e/test_job_ingestion.py +++ b/tests/e2e/test_job_ingestion.py @@ -4,6 +4,7 @@ import json import pytest from django.forms import model_to_dict from mock import MagicMock +from six import PY3 from tests.test_utils import add_log_response from treeherder.client.thclient import client @@ -53,6 +54,7 @@ def check_job_log(test_repository, job_guid, parse_status): assert job_logs[0].status == parse_status +@pytest.mark.xfail(PY3, reason='Python 3: a bytes-like object is required, not str (bug 1526743)') def test_store_job_with_unparsed_log(test_repository, failure_classifications, push_stored, monkeypatch, activate_responses): """ @@ -97,6 +99,7 @@ def test_store_job_with_unparsed_log(test_repository, failure_classifications, assert len(get_error_summary(Job.objects.get(id=1))) == 2 +@pytest.mark.xfail(PY3, reason='Python 3: a bytes-like object is required, not str (bug 1526743)') def test_store_job_pending_to_completed_with_unparsed_log(test_repository, push_stored, failure_classifications, activate_responses): diff --git a/tests/etl/test_load_artifacts.py b/tests/etl/test_load_artifacts.py index b67b17f05..f8fa52f14 100644 --- a/tests/etl/test_load_artifacts.py +++ b/tests/etl/test_load_artifacts.py @@ -2,15 +2,11 @@ from __future__ import unicode_literals import json -import pytest - from treeherder.etl.artifact import store_job_artifacts from treeherder.model.models import (JobDetail, TextLogError, TextLogStep) -xfail = pytest.mark.xfail - def test_load_long_job_details(test_job): def max_length(field): diff --git a/tests/log_parser/test_job_artifact_builder.py b/tests/log_parser/test_job_artifact_builder.py index c6ef9c6fc..070c743f5 100644 --- a/tests/log_parser/test_job_artifact_builder.py +++ b/tests/log_parser/test_job_artifact_builder.py @@ -1,10 +1,14 @@ +import pytest import responses +from six import PY3 from tests import test_utils from tests.test_utils import add_log_response from treeherder.log_parser.artifactbuildercollection import ArtifactBuilderCollection from treeherder.log_parser.artifactbuilders import BuildbotJobArtifactBuilder +pytestmark = pytest.mark.xfail(PY3, reason='Python 3: a bytes-like object is required, not str (bug 1526743)') + @responses.activate def do_test(log): diff --git a/tests/log_parser/test_log_view_artifact_builder.py b/tests/log_parser/test_log_view_artifact_builder.py index 49728f8b6..03d921a6e 100644 --- a/tests/log_parser/test_log_view_artifact_builder.py +++ b/tests/log_parser/test_log_view_artifact_builder.py @@ -1,5 +1,6 @@ import pytest import responses +from six import PY3 from tests import test_utils from tests.test_utils import add_log_response @@ -8,6 +9,8 @@ from treeherder.log_parser.artifactbuilders import BuildbotLogViewArtifactBuilde slow = pytest.mark.slow +pytestmark = pytest.mark.xfail(PY3, reason='Python 3: a bytes-like object is required, not str (bug 1526743)') + @responses.activate def do_test(log): diff --git a/tests/log_parser/test_performance_artifact_builder.py b/tests/log_parser/test_performance_artifact_builder.py index 5dbdc686c..99c185c0e 100644 --- a/tests/log_parser/test_performance_artifact_builder.py +++ b/tests/log_parser/test_performance_artifact_builder.py @@ -1,5 +1,7 @@ +import pytest import responses from jsonschema import validate +from six import PY3 from tests.test_utils import add_log_response from treeherder.etl.perf import PERFHERDER_SCHEMA @@ -7,6 +9,7 @@ from treeherder.log_parser.artifactbuildercollection import ArtifactBuilderColle from treeherder.log_parser.artifactbuilders import BuildbotPerformanceDataArtifactBuilder +@pytest.mark.xfail(PY3, reason='Python 3: a bytes-like object is required, not str (bug 1526743)') @responses.activate def test_performance_log_parsing(): """ diff --git a/tests/log_parser/test_tasks.py b/tests/log_parser/test_tasks.py index a72463843..6745f3e9d 100644 --- a/tests/log_parser/test_tasks.py +++ b/tests/log_parser/test_tasks.py @@ -1,6 +1,7 @@ from __future__ import print_function import pytest +from six import PY3 from tests.test_utils import add_log_response from treeherder.etl.jobs import store_job_data @@ -27,6 +28,7 @@ def jobs_with_local_log(activate_responses): return [job] +@pytest.mark.xfail(PY3, reason='Python 3: a bytes-like object is required, not str (bug 1526743)') def test_parse_log(test_repository, failure_classifications, jobs_with_local_log, sample_push): """ check that 2 job_artifacts get inserted when running a parse_log task for @@ -47,6 +49,7 @@ def test_parse_log(test_repository, failure_classifications, jobs_with_local_log print(JobDetail.objects.count() == 4) +@pytest.mark.xfail(PY3, reason='Python 3: a bytes-like object is required, not str (bug 1526743)') def test_create_error_summary(failure_classifications, jobs_with_local_log, sample_push, test_repository): diff --git a/tests/webapp/api/test_auth.py b/tests/webapp/api/test_auth.py index df8c28801..586f62557 100644 --- a/tests/webapp/api/test_auth.py +++ b/tests/webapp/api/test_auth.py @@ -8,6 +8,7 @@ from rest_framework import status from rest_framework.decorators import APIView from rest_framework.response import Response from rest_framework.test import APIRequestFactory +from six import PY3 from treeherder.auth.backends import AuthBackend from treeherder.model.models import User @@ -47,6 +48,7 @@ def test_post_no_auth(): # Auth Login and Logout Tests +@pytest.mark.xfail(PY3, reason='Python 3: < not supported between instances of str and int (bug 1453837)') def test_auth_login_and_logout(test_ldap_user, client, monkeypatch): """LDAP login user exists, has scope: find by email""" def userinfo_mock(selfless, request): @@ -136,6 +138,7 @@ def test_login_no_email(test_user, client, monkeypatch): assert resp.json()["detail"] == "Unrecognized identity" +@pytest.mark.xfail(PY3, reason='Python 3: < not supported between instances of str and int (bug 1453837)') @pytest.mark.django_db def test_login_not_active(test_ldap_user, client, monkeypatch): """LDAP login, user not active"""