diff --git a/cms/envs/test.py b/cms/envs/test.py index ec85b7a9a23a4aa3dcc6c84dd4e046a62ed93bcd..166af8268c2acb668de45f0e3c85f03d0a3493c3 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -21,6 +21,7 @@ sessions. Assumes structure: from .common import * import os from path import Path as path +from warnings import filterwarnings, simplefilter from uuid import uuid4 from util.db import NoOpMigrationModules from openedx.core.lib.derived import derive_settings @@ -174,6 +175,15 @@ CACHES = { }, } +# hide ratelimit warnings while running tests +filterwarnings('ignore', message='No request passed to the backend, unable to rate-limit') + +# Ignore deprecation warnings (so we don't clutter Jenkins builds/production) +# https://docs.python.org/2/library/warnings.html#the-warnings-filter +# Change to "default" to see the first instance of each hit +# or "error" to convert all into errors +simplefilter('ignore') + ################################# CELERY ###################################### CELERY_ALWAYS_EAGER = True diff --git a/cms/pytest.ini b/cms/pytest.ini index cf4d8324a466273ea5d4bf9a0e218a75000ca1b7..c12268a41fb15ace22362f3b70a328436f70f9c1 100644 --- a/cms/pytest.ini +++ b/cms/pytest.ini @@ -1,11 +1,6 @@ [pytest] DJANGO_SETTINGS_MODULE = cms.envs.test addopts = --nomigrations --reuse-db --durations=20 -p no:randomly -# Enable default handling for all warnings, including those that are ignored by default; -# but hide rate-limit warnings, because we deliberately don't throttle test user logins -filterwarnings = - default - ignore:No request passed to the backend, unable to rate-limit.*:UserWarning norecursedirs = envs python_classes = python_files = tests.py test_*.py *_tests.py diff --git a/common/djangoapps/student/views.py b/common/djangoapps/student/views.py index 98699a1f76a7db26f3f05981046dcb3d305a1c1c..5c07b4585d310a1df4ccf86ace3249f26d959664 100644 --- a/common/djangoapps/student/views.py +++ b/common/djangoapps/student/views.py @@ -2437,9 +2437,7 @@ def auto_auth(request): # Log in as the user if login_when_done: - backend = load_backend(NEW_USER_AUTH_BACKEND) - user = backend.authenticate(request=request, username=username, password=password) - user.backend = NEW_USER_AUTH_BACKEND + user = authenticate(username=username, password=password) login(request, user) create_comments_service_user(user) diff --git a/common/lib/pytest.ini b/common/lib/pytest.ini index e85793143ff3248c49a1b7f9bfdfa840f0784530..349b1dff15e80dd7e0b48e86ebe93a125cf50f1e 100644 --- a/common/lib/pytest.ini +++ b/common/lib/pytest.ini @@ -1,11 +1,6 @@ [pytest] DJANGO_SETTINGS_MODULE = openedx.tests.settings addopts = --nomigrations --reuse-db --durations=20 -# Enable default handling for all warnings, including those that are ignored by default; -# but hide rate-limit warnings, because we deliberately don't throttle test user logins -filterwarnings = - default - ignore:No request passed to the backend, unable to rate-limit.*:UserWarning norecursedirs = .cache python_classes = python_files = tests.py test_*.py tests_*.py *_tests.py __init__.py diff --git a/common/test/pytest.ini b/common/test/pytest.ini index 57251b8fb7e68450ff049518ff502fb8718db5e2..d8172d2726fd9064f8bf119a65e99c93f70a6665 100644 --- a/common/test/pytest.ini +++ b/common/test/pytest.ini @@ -1,8 +1,3 @@ [pytest] addopts = -p no:randomly --durations=20 -# Enable default handling for all warnings, including those that are ignored by default; -# but hide rate-limit warnings, because we deliberately don't throttle test user logins -filterwarnings = - default - ignore:No request passed to the backend, unable to rate-limit.*:UserWarning norecursedirs = .cache diff --git a/lms/envs/test.py b/lms/envs/test.py index e64aeebfa3beafdc93b1474dcdb0e4119df5d72e..f717b65a550bc7a7c038566fd77970c294121059 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -22,6 +22,7 @@ from .common import * import os from path import Path as path from uuid import uuid4 +from warnings import filterwarnings, simplefilter from util.db import NoOpMigrationModules from openedx.core.lib.derived import derive_settings @@ -230,6 +231,15 @@ CACHES = { # Dummy secret key for dev SECRET_KEY = '85920908f28904ed733fe576320db18cabd7b6cd' +# hide ratelimit warnings while running tests +filterwarnings('ignore', message='No request passed to the backend, unable to rate-limit') + +# Ignore deprecation warnings (so we don't clutter Jenkins builds/production) +# https://docs.python.org/2/library/warnings.html#the-warnings-filter +# Change to "default" to see the first instance of each hit +# or "error" to convert all into errors +simplefilter('ignore') + ############################# SECURITY SETTINGS ################################ # Default to advanced security in common.py, so tests can reset here to use # a simpler security model diff --git a/openedx/tests/settings.py b/openedx/tests/settings.py index ccfc7217be154438a13e5caf8ef609f35d1167f5..85e1df4f717c9a0eda38ec0be6d340cfab7d422e 100644 --- a/openedx/tests/settings.py +++ b/openedx/tests/settings.py @@ -58,12 +58,10 @@ INSTALLED_APPS = ( 'djcelery', 'openedx.core.djangoapps.video_config', 'openedx.core.djangoapps.video_pipeline', - 'openedx.core.djangoapps.bookmarks.apps.BookmarksConfig', 'edxval', 'courseware', 'student', 'certificates.apps.CertificatesConfig', - 'openedx.core.djangoapps.user_api', 'course_modes.apps.CourseModesConfig', 'lms.djangoapps.verify_student.apps.VerifyStudentConfig', 'openedx.core.djangoapps.dark_lang', @@ -73,7 +71,6 @@ INSTALLED_APPS = ( 'openedx.core.djangoapps.self_paced', 'milestones', 'celery_utils', - 'lms.djangoapps.completion.apps.CompletionAppConfig', ) LMS_ROOT_URL = 'http://localhost:8000' diff --git a/openedx/tests/util/__init__.py b/openedx/tests/util/__init__.py index 0db3fb023f8e202bec0b365427816559771105de..b9835638df360c510b97aaa04365b4858db4ea2c 100644 --- a/openedx/tests/util/__init__.py +++ b/openedx/tests/util/__init__.py @@ -11,20 +11,10 @@ import django def expected_redirect_url(relative_url, hostname='testserver'): """ Get the expected redirect URL for the current Django version and the - given relative URL: - - * Django 1.8 and earlier redirect URLs beginning with a slash to absolute - URLs, later versions redirect to relative ones. - * Django 1.8 and earlier leave URLs without a leading slash alone, later - versions prepend the missing slash. + given relative URL. Django 1.8 and earlier redirect to absolute URLs, + later versions redirect to relative ones. """ if django.VERSION < (1, 9): - if relative_url.startswith('/'): - return 'http://{}{}'.format(hostname, relative_url) - else: - return relative_url + return 'http://{}{}'.format(hostname, relative_url) else: - if relative_url.startswith('/'): - return relative_url - else: - return '/{}'.format(relative_url) + return relative_url diff --git a/pavelib/tests.py b/pavelib/tests.py index fc66984b688aabcec907fc3c5d7c8e6324ff55a7..808c09f266f3924f3bce78f7af6e25e2864788c6 100644 --- a/pavelib/tests.py +++ b/pavelib/tests.py @@ -65,7 +65,6 @@ __test__ = False # do not collect dest='disable_migrations', help="Create tables by applying migrations." ), - make_option('--stderr', help='redirect stderr from tests to a file at this path'), ], share_with=['pavelib.utils.test.utils.clean_reports_dir']) @PassthroughTask @timed @@ -141,7 +140,6 @@ def test_system(options, passthrough_options): "--disable_capture", action="store_true", dest="disable_capture", help="Disable capturing of stdout/stderr" ), - make_option('--stderr', help='redirect stderr from tests to a file at this path'), ], share_with=['pavelib.utils.test.utils.clean_reports_dir']) @PassthroughTask @timed diff --git a/pavelib/utils/test/suites/suite.py b/pavelib/utils/test/suites/suite.py index 8830233960327ca83dc5a448fb506441114f5201..74ee8f708af91e135cbdbc57b7435f18a495f26e 100644 --- a/pavelib/utils/test/suites/suite.py +++ b/pavelib/utils/test/suites/suite.py @@ -1,7 +1,6 @@ """ A class used for defining and running test suites """ -import os import sys import subprocess @@ -28,7 +27,6 @@ class TestSuite(object): self.verbosity = int(kwargs.get('verbosity', 1)) self.skip_clean = kwargs.get('skip_clean', False) self.passthrough_options = kwargs.get('passthrough_options', []) - self.stderr_path = kwargs.get('stderr', None) def __enter__(self): """ @@ -93,10 +91,6 @@ class TestSuite(object): sys.stdout.flush() kwargs = {'shell': True, 'cwd': None} - stderr = None - if self.stderr_path: - stderr = open(self.stderr_path, 'a') - kwargs['stderr'] = stderr process = None try: @@ -105,17 +99,12 @@ class TestSuite(object): except KeyboardInterrupt: kill_process(process) sys.exit(1) - finally: - if stderr: - stderr.close() def run_suite_tests(self): """ Runs each of the suites in self.subsuites while tracking failures """ # Uses __enter__ and __exit__ for context - if self.stderr_path and os.path.isfile(self.stderr_path): - os.remove(self.stderr_path) with self: # run the tests for this class, and for all subsuites if self.cmd: diff --git a/scripts/generic-ci-tests.sh b/scripts/generic-ci-tests.sh index 51e7db78856de210bd7331ee67fbcf5abe755add..fcc99748ad8896de131345d318fb58765caac309 100755 --- a/scripts/generic-ci-tests.sh +++ b/scripts/generic-ci-tests.sh @@ -132,13 +132,13 @@ case "$TEST_SUITE" in "lms-unit") case "$SHARD" in "all") - $TOX paver test_system -s lms --disable_capture $PAVER_ARGS $PARALLEL --stderr=lms-tests.log + $TOX paver test_system -s lms --disable_capture $PAVER_ARGS $PARALLEL 2> lms-tests.log ;; [1-3]) - $TOX paver test_system -s lms --disable_capture --eval-attr="shard==$SHARD" $PAVER_ARGS $PARALLEL --stderr=lms-tests.$SHARD.log + $TOX paver test_system -s lms --disable_capture --eval-attr="shard==$SHARD" $PAVER_ARGS $PARALLEL 2> lms-tests.$SHARD.log ;; 4|"noshard") - $TOX paver test_system -s lms --disable_capture --eval-attr='not shard' $PAVER_ARGS $PARALLEL --stderr=lms-tests.4.log + $TOX paver test_system -s lms --disable_capture --eval-attr='not shard' $PAVER_ARGS $PARALLEL 2> lms-tests.4.log ;; *) # If no shard is specified, rather than running all tests, create an empty xunit file. This is a @@ -152,11 +152,11 @@ case "$TEST_SUITE" in ;; "cms-unit") - $TOX paver test_system -s cms --disable_capture $PAVER_ARGS --stderr=cms-tests.log + $TOX paver test_system -s cms --disable_capture $PAVER_ARGS 2> cms-tests.log ;; "commonlib-unit") - $TOX paver test_lib --disable_capture $PAVER_ARGS --stderr=common-tests.log + $TOX paver test_lib --disable_capture $PAVER_ARGS 2> common-tests.log ;; "js-unit") diff --git a/setup.cfg b/setup.cfg index c2c454a69d0b3a14b78140e2694c7d3695f503e6..0c96005f232b6075a51fb11e0f8e500b2d6a28dd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,11 +17,6 @@ process-timeout=300 [tool:pytest] DJANGO_SETTINGS_MODULE = lms.envs.test addopts = --nomigrations --reuse-db --durations=20 -# Enable default handling for all warnings, including those that are ignored by default; -# but hide rate-limit warnings, because we deliberately don't throttle test user logins -filterwarnings = - default - ignore:No request passed to the backend, unable to rate-limit.*:UserWarning norecursedirs = .* *.egg build conf dist node_modules test_root cms/envs lms/envs python_classes = python_files = tests.py test_*.py tests_*.py *_tests.py __init__.py