diff --git a/.travis.yml b/.travis.yml index 7d50ba8aff..4bf8ed308e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ env: - TOXENV=addons - TOXENV=devhub - TOXENV=reviewers - - TOXENV=amo + - TOXENV=amo-and-locales - TOXENV=users - TOXENV=main diff --git a/setup.cfg b/setup.cfg index 56d1b2032a..53c48b273c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,6 +3,7 @@ addopts = -vs --reuse-db --showlocals --tb=short python_files=test*.py markers = es_tests: mark a test as an elasticsearch test. + needs_locales_compilation: mark a test as needing compiled locales to work. norecursedirs = node_modules locale static media site-static user-media tmp templates fixtures migrations diff --git a/src/olympia/addons/tests/test_models.py b/src/olympia/addons/tests/test_models.py index d5389c246c..33d8d02081 100644 --- a/src/olympia/addons/tests/test_models.py +++ b/src/olympia/addons/tests/test_models.py @@ -13,6 +13,7 @@ from django.core.files.storage import default_storage as storage from django.db import IntegrityError from django.utils import translation +import pytest from mock import Mock, patch from olympia import amo, core @@ -1920,6 +1921,7 @@ class TestCategoryModel(TestCase): cat = Category(type=t, slug='omg') assert cat.get_url_path() + @pytest.mark.needs_locales_compilation def test_name_from_constants(self): category = Category( type=amo.ADDON_EXTENSION, application=amo.FIREFOX.id, diff --git a/src/olympia/addons/tests/test_views.py b/src/olympia/addons/tests/test_views.py index e34ecfa142..be6a686ae9 100644 --- a/src/olympia/addons/tests/test_views.py +++ b/src/olympia/addons/tests/test_views.py @@ -9,6 +9,7 @@ from django.core.cache import cache from django.test.client import Client from django.utils.http import urlunquote +import pytest import waffle from elasticsearch import Elasticsearch @@ -3229,6 +3230,7 @@ class TestStaticCategoryView(TestCase): u'slug': u'feeds-news-blogging' } + @pytest.mark.needs_locales_compilation def test_name_translated(self): with self.assertNumQueries(0): response = self.client.get(self.url, HTTP_ACCEPT_LANGUAGE='de') diff --git a/src/olympia/amo/tests/test_views.py b/src/olympia/amo/tests/test_views.py index f14ed50f4e..a54a25d954 100644 --- a/src/olympia/amo/tests/test_views.py +++ b/src/olympia/amo/tests/test_views.py @@ -310,6 +310,7 @@ class TestOtherStuff(TestCase): self.assertCloseToNow(response['Expires'], now=datetime.now() + timedelta(days=365)) + @pytest.mark.needs_locales_compilation def test_jsi18n(self): """Test that the jsi18n library has an actual catalog of translations rather than just identity functions.""" diff --git a/src/olympia/devhub/tests/test_forms.py b/src/olympia/devhub/tests/test_forms.py index 8b3f5ad478..f75a5c7913 100644 --- a/src/olympia/devhub/tests/test_forms.py +++ b/src/olympia/devhub/tests/test_forms.py @@ -754,6 +754,7 @@ class TestEditThemeOwnerForm(TestCase): class TestDistributionChoiceForm(TestCase): + @pytest.mark.needs_locales_compilation def test_lazy_choice_labels(self): """Tests that the labels in `choices` are still lazy diff --git a/src/olympia/files/tests/test_helpers.py b/src/olympia/files/tests/test_helpers.py index 0ff6d68d99..d3c849ae27 100644 --- a/src/olympia/files/tests/test_helpers.py +++ b/src/olympia/files/tests/test_helpers.py @@ -252,6 +252,7 @@ class TestFileViewer(TestCase): assert res == '' assert self.viewer.selected['msg'].startswith('File size is') + @pytest.mark.needs_locales_compilation @patch.object(settings, 'FILE_VIEWER_SIZE_LIMIT', 5) def test_file_size_unicode(self): with self.activate(locale='he'): diff --git a/src/olympia/reviewers/tests/test_views_themes.py b/src/olympia/reviewers/tests/test_views_themes.py index 5e281bc1d8..9d54c99cde 100644 --- a/src/olympia/reviewers/tests/test_views_themes.py +++ b/src/olympia/reviewers/tests/test_views_themes.py @@ -6,6 +6,7 @@ from django.conf import settings from django.utils.encoding import smart_text import mock +import pytest from pyquery import PyQuery as pq @@ -94,6 +95,7 @@ class ThemeReviewTestMixin(object): assert ThemeLock.objects.filter(reviewer=reviewer).count() == ( len(expected)) + @pytest.mark.needs_locales_compilation @mock.patch('olympia.amo.messages.success') @mock.patch('olympia.reviewers.tasks.reject_rereview') @mock.patch('olympia.reviewers.tasks.approve_rereview') diff --git a/tox.ini b/tox.ini index a4ef25a8ba..f517744b69 100644 --- a/tox.ini +++ b/tox.ini @@ -17,44 +17,39 @@ whitelist_externals = [testenv:es] commands = make -f Makefile-docker update_deps - bash {toxinidir}/locale/compile-mo.sh {toxinidir}/locale/ - py.test -m es_tests --ignore=tests/ui/ -v {posargs} + py.test -m "es_tests and not needs_locales_compilation" --ignore=tests/ui/ -v {posargs} [testenv:addons] commands = make -f Makefile-docker update_deps - bash {toxinidir}/locale/compile-mo.sh {toxinidir}/locale/ - py.test -n 2 -m 'not es_tests' -v src/olympia/addons/ {posargs} + py.test -n 2 -m 'not es_tests and not needs_locales_compilation' -v src/olympia/addons/ {posargs} [testenv:devhub] commands = make -f Makefile-docker update_deps - bash {toxinidir}/locale/compile-mo.sh {toxinidir}/locale/ - py.test -n 2 -m 'not es_tests' -v src/olympia/devhub/ {posargs} + py.test -n 2 -m 'not es_tests and not needs_locales_compilation' -v src/olympia/devhub/ {posargs} [testenv:reviewers] commands = make -f Makefile-docker update_deps - bash {toxinidir}/locale/compile-mo.sh {toxinidir}/locale/ - py.test -n 2 -m 'not es_tests' -v src/olympia/reviewers/ {posargs} + py.test -n 2 -m 'not es_tests and not needs_locales_compilation' -v src/olympia/reviewers/ {posargs} -[testenv:amo] +[testenv:amo-and-locales] commands = make -f Makefile-docker update_deps bash {toxinidir}/locale/compile-mo.sh {toxinidir}/locale/ - py.test -n 2 -m 'not es_tests' -v src/olympia/amo/ {posargs} + py.test -n 2 -m 'not es_tests and not needs_locales_compilation' -v src/olympia/amo/ {posargs} + py.test -n 2 -m 'needs_locales_compilation' -v src/olympia/ {posargs} [testenv:users] commands = make -f Makefile-docker update_deps - bash {toxinidir}/locale/compile-mo.sh {toxinidir}/locale/ - py.test -n 2 -m 'not es_tests' -v src/olympia/users/ {posargs} + py.test -n 2 -m 'not es_tests and not needs_locales_compilation' -v src/olympia/users/ {posargs} [testenv:main] commands = make -f Makefile-docker update_deps - bash {toxinidir}/locale/compile-mo.sh {toxinidir}/locale/ - py.test -n 2 -m 'not es_tests' -v src/olympia/ --ignore src/olympia/addons/ --ignore src/olympia/devhub/ --ignore src/olympia/reviewers/ --ignore src/olympia/amo/ --ignore src/olympia/users/ {posargs} + py.test -n 2 -m 'not es_tests and not needs_locales_compilation' -v src/olympia/ --ignore src/olympia/addons/ --ignore src/olympia/devhub/ --ignore src/olympia/reviewers/ --ignore src/olympia/amo/ --ignore src/olympia/users/ {posargs} [testenv:ui-tests] commands =