Unverified Commit 1dbdee9c by Jeremy Bowman Committed by GitHub

Revert "PLAT-1858 Better capture of deprecation warnings"

parent 5e2c3e4b
...@@ -21,6 +21,7 @@ sessions. Assumes structure: ...@@ -21,6 +21,7 @@ sessions. Assumes structure:
from .common import * from .common import *
import os import os
from path import Path as path from path import Path as path
from warnings import filterwarnings, simplefilter
from uuid import uuid4 from uuid import uuid4
from util.db import NoOpMigrationModules from util.db import NoOpMigrationModules
from openedx.core.lib.derived import derive_settings from openedx.core.lib.derived import derive_settings
...@@ -174,6 +175,15 @@ CACHES = { ...@@ -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 ######################################
CELERY_ALWAYS_EAGER = True CELERY_ALWAYS_EAGER = True
......
[pytest] [pytest]
DJANGO_SETTINGS_MODULE = cms.envs.test DJANGO_SETTINGS_MODULE = cms.envs.test
addopts = --nomigrations --reuse-db --durations=20 -p no:randomly 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 norecursedirs = envs
python_classes = python_classes =
python_files = tests.py test_*.py *_tests.py python_files = tests.py test_*.py *_tests.py
...@@ -2437,9 +2437,7 @@ def auto_auth(request): ...@@ -2437,9 +2437,7 @@ def auto_auth(request):
# Log in as the user # Log in as the user
if login_when_done: if login_when_done:
backend = load_backend(NEW_USER_AUTH_BACKEND) user = authenticate(username=username, password=password)
user = backend.authenticate(request=request, username=username, password=password)
user.backend = NEW_USER_AUTH_BACKEND
login(request, user) login(request, user)
create_comments_service_user(user) create_comments_service_user(user)
......
[pytest] [pytest]
DJANGO_SETTINGS_MODULE = openedx.tests.settings DJANGO_SETTINGS_MODULE = openedx.tests.settings
addopts = --nomigrations --reuse-db --durations=20 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 norecursedirs = .cache
python_classes = python_classes =
python_files = tests.py test_*.py tests_*.py *_tests.py __init__.py python_files = tests.py test_*.py tests_*.py *_tests.py __init__.py
[pytest] [pytest]
addopts = -p no:randomly --durations=20 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 norecursedirs = .cache
...@@ -22,6 +22,7 @@ from .common import * ...@@ -22,6 +22,7 @@ from .common import *
import os import os
from path import Path as path from path import Path as path
from uuid import uuid4 from uuid import uuid4
from warnings import filterwarnings, simplefilter
from util.db import NoOpMigrationModules from util.db import NoOpMigrationModules
from openedx.core.lib.derived import derive_settings from openedx.core.lib.derived import derive_settings
...@@ -230,6 +231,15 @@ CACHES = { ...@@ -230,6 +231,15 @@ CACHES = {
# Dummy secret key for dev # Dummy secret key for dev
SECRET_KEY = '85920908f28904ed733fe576320db18cabd7b6cd' 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 ################################ ############################# SECURITY SETTINGS ################################
# Default to advanced security in common.py, so tests can reset here to use # Default to advanced security in common.py, so tests can reset here to use
# a simpler security model # a simpler security model
......
...@@ -58,12 +58,10 @@ INSTALLED_APPS = ( ...@@ -58,12 +58,10 @@ INSTALLED_APPS = (
'djcelery', 'djcelery',
'openedx.core.djangoapps.video_config', 'openedx.core.djangoapps.video_config',
'openedx.core.djangoapps.video_pipeline', 'openedx.core.djangoapps.video_pipeline',
'openedx.core.djangoapps.bookmarks.apps.BookmarksConfig',
'edxval', 'edxval',
'courseware', 'courseware',
'student', 'student',
'certificates.apps.CertificatesConfig', 'certificates.apps.CertificatesConfig',
'openedx.core.djangoapps.user_api',
'course_modes.apps.CourseModesConfig', 'course_modes.apps.CourseModesConfig',
'lms.djangoapps.verify_student.apps.VerifyStudentConfig', 'lms.djangoapps.verify_student.apps.VerifyStudentConfig',
'openedx.core.djangoapps.dark_lang', 'openedx.core.djangoapps.dark_lang',
...@@ -73,7 +71,6 @@ INSTALLED_APPS = ( ...@@ -73,7 +71,6 @@ INSTALLED_APPS = (
'openedx.core.djangoapps.self_paced', 'openedx.core.djangoapps.self_paced',
'milestones', 'milestones',
'celery_utils', 'celery_utils',
'lms.djangoapps.completion.apps.CompletionAppConfig',
) )
LMS_ROOT_URL = 'http://localhost:8000' LMS_ROOT_URL = 'http://localhost:8000'
......
...@@ -11,20 +11,10 @@ import django ...@@ -11,20 +11,10 @@ import django
def expected_redirect_url(relative_url, hostname='testserver'): def expected_redirect_url(relative_url, hostname='testserver'):
""" """
Get the expected redirect URL for the current Django version and the Get the expected redirect URL for the current Django version and the
given relative URL: given relative URL. Django 1.8 and earlier redirect to absolute URLs,
later versions redirect to relative ones.
* 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.
""" """
if django.VERSION < (1, 9): if django.VERSION < (1, 9):
if relative_url.startswith('/'): return 'http://{}{}'.format(hostname, relative_url)
return 'http://{}{}'.format(hostname, relative_url)
else:
return relative_url
else: else:
if relative_url.startswith('/'): return relative_url
return relative_url
else:
return '/{}'.format(relative_url)
...@@ -65,7 +65,6 @@ __test__ = False # do not collect ...@@ -65,7 +65,6 @@ __test__ = False # do not collect
dest='disable_migrations', dest='disable_migrations',
help="Create tables by applying 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']) ], share_with=['pavelib.utils.test.utils.clean_reports_dir'])
@PassthroughTask @PassthroughTask
@timed @timed
...@@ -141,7 +140,6 @@ def test_system(options, passthrough_options): ...@@ -141,7 +140,6 @@ def test_system(options, passthrough_options):
"--disable_capture", action="store_true", dest="disable_capture", "--disable_capture", action="store_true", dest="disable_capture",
help="Disable capturing of stdout/stderr" 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']) ], share_with=['pavelib.utils.test.utils.clean_reports_dir'])
@PassthroughTask @PassthroughTask
@timed @timed
......
""" """
A class used for defining and running test suites A class used for defining and running test suites
""" """
import os
import sys import sys
import subprocess import subprocess
...@@ -28,7 +27,6 @@ class TestSuite(object): ...@@ -28,7 +27,6 @@ class TestSuite(object):
self.verbosity = int(kwargs.get('verbosity', 1)) self.verbosity = int(kwargs.get('verbosity', 1))
self.skip_clean = kwargs.get('skip_clean', False) self.skip_clean = kwargs.get('skip_clean', False)
self.passthrough_options = kwargs.get('passthrough_options', []) self.passthrough_options = kwargs.get('passthrough_options', [])
self.stderr_path = kwargs.get('stderr', None)
def __enter__(self): def __enter__(self):
""" """
...@@ -93,10 +91,6 @@ class TestSuite(object): ...@@ -93,10 +91,6 @@ class TestSuite(object):
sys.stdout.flush() sys.stdout.flush()
kwargs = {'shell': True, 'cwd': None} kwargs = {'shell': True, 'cwd': None}
stderr = None
if self.stderr_path:
stderr = open(self.stderr_path, 'a')
kwargs['stderr'] = stderr
process = None process = None
try: try:
...@@ -105,17 +99,12 @@ class TestSuite(object): ...@@ -105,17 +99,12 @@ class TestSuite(object):
except KeyboardInterrupt: except KeyboardInterrupt:
kill_process(process) kill_process(process)
sys.exit(1) sys.exit(1)
finally:
if stderr:
stderr.close()
def run_suite_tests(self): def run_suite_tests(self):
""" """
Runs each of the suites in self.subsuites while tracking failures Runs each of the suites in self.subsuites while tracking failures
""" """
# Uses __enter__ and __exit__ for context # Uses __enter__ and __exit__ for context
if self.stderr_path and os.path.isfile(self.stderr_path):
os.remove(self.stderr_path)
with self: with self:
# run the tests for this class, and for all subsuites # run the tests for this class, and for all subsuites
if self.cmd: if self.cmd:
......
...@@ -132,13 +132,13 @@ case "$TEST_SUITE" in ...@@ -132,13 +132,13 @@ case "$TEST_SUITE" in
"lms-unit") "lms-unit")
case "$SHARD" in case "$SHARD" in
"all") "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]) [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") 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 # 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 ...@@ -152,11 +152,11 @@ case "$TEST_SUITE" in
;; ;;
"cms-unit") "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") "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") "js-unit")
......
...@@ -17,11 +17,6 @@ process-timeout=300 ...@@ -17,11 +17,6 @@ process-timeout=300
[tool:pytest] [tool:pytest]
DJANGO_SETTINGS_MODULE = lms.envs.test DJANGO_SETTINGS_MODULE = lms.envs.test
addopts = --nomigrations --reuse-db --durations=20 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 norecursedirs = .* *.egg build conf dist node_modules test_root cms/envs lms/envs
python_classes = python_classes =
python_files = tests.py test_*.py tests_*.py *_tests.py __init__.py python_files = tests.py test_*.py tests_*.py *_tests.py __init__.py
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment