diff options
| -rw-r--r-- | .travis.yml | 3 | ||||
| -rw-r--r-- | CONTRIBUTING.md | 2 | ||||
| -rw-r--r-- | conftest.py | 85 | ||||
| -rw-r--r-- | docs/index.md | 16 | ||||
| -rw-r--r-- | docs/topics/contributing.md | 2 | ||||
| -rw-r--r-- | pytest.ini | 2 | ||||
| -rw-r--r-- | requirements.txt | 2 | ||||
| -rwxr-xr-x | rest_framework/runtests/runcoverage.py | 78 | ||||
| -rwxr-xr-x | rest_framework/runtests/runtests.py | 52 | ||||
| -rw-r--r-- | rest_framework/runtests/urls.py | 7 | ||||
| -rw-r--r-- | rest_framework/tests/tests.py | 16 | ||||
| -rw-r--r-- | rest_framework/tests/users/__init__.py | 0 | ||||
| -rwxr-xr-x | setup.py | 17 | ||||
| -rw-r--r-- | tests/__init__.py (renamed from rest_framework/runtests/__init__.py) | 0 | ||||
| -rw-r--r-- | tests/accounts/__init__.py (renamed from rest_framework/tests/__init__.py) | 0 | ||||
| -rw-r--r-- | tests/accounts/models.py (renamed from rest_framework/tests/accounts/models.py) | 2 | ||||
| -rw-r--r-- | tests/accounts/serializers.py (renamed from rest_framework/tests/accounts/serializers.py) | 4 | ||||
| -rw-r--r-- | tests/description.py (renamed from rest_framework/tests/description.py) | 0 | ||||
| -rw-r--r-- | tests/extras/__init__.py (renamed from rest_framework/tests/accounts/__init__.py) | 0 | ||||
| -rw-r--r-- | tests/extras/bad_import.py (renamed from rest_framework/tests/extras/bad_import.py) | 0 | ||||
| -rw-r--r-- | tests/models.py (renamed from rest_framework/tests/models.py) | 0 | ||||
| -rw-r--r-- | tests/records/__init__.py (renamed from rest_framework/tests/extras/__init__.py) | 0 | ||||
| -rw-r--r-- | tests/records/models.py (renamed from rest_framework/tests/records/models.py) | 0 | ||||
| -rw-r--r-- | tests/serializers.py (renamed from rest_framework/tests/serializers.py) | 2 | ||||
| -rw-r--r-- | tests/settings.py (renamed from rest_framework/runtests/settings.py) | 10 | ||||
| -rw-r--r-- | tests/test_authentication.py (renamed from rest_framework/tests/test_authentication.py) | 10 | ||||
| -rw-r--r-- | tests/test_breadcrumbs.py (renamed from rest_framework/tests/test_breadcrumbs.py) | 2 | ||||
| -rw-r--r-- | tests/test_decorators.py (renamed from rest_framework/tests/test_decorators.py) | 0 | ||||
| -rw-r--r-- | tests/test_description.py (renamed from rest_framework/tests/test_description.py) | 4 | ||||
| -rw-r--r-- | tests/test_fields.py (renamed from rest_framework/tests/test_fields.py) | 2 | ||||
| -rw-r--r-- | tests/test_files.py (renamed from rest_framework/tests/test_files.py) | 0 | ||||
| -rw-r--r-- | tests/test_filters.py (renamed from rest_framework/tests/test_filters.py) | 5 | ||||
| -rw-r--r-- | tests/test_genericrelations.py (renamed from rest_framework/tests/test_genericrelations.py) | 0 | ||||
| -rw-r--r-- | tests/test_generics.py (renamed from rest_framework/tests/test_generics.py) | 2 | ||||
| -rw-r--r-- | tests/test_htmlrenderer.py (renamed from rest_framework/tests/test_htmlrenderer.py) | 4 | ||||
| -rw-r--r-- | tests/test_hyperlinkedserializers.py (renamed from rest_framework/tests/test_hyperlinkedserializers.py) | 18 | ||||
| -rw-r--r-- | tests/test_multitable_inheritance.py (renamed from rest_framework/tests/test_multitable_inheritance.py) | 2 | ||||
| -rw-r--r-- | tests/test_negotiation.py (renamed from rest_framework/tests/test_negotiation.py) | 0 | ||||
| -rw-r--r-- | tests/test_nullable_fields.py (renamed from rest_framework/tests/test_nullable_fields.py) | 8 | ||||
| -rw-r--r-- | tests/test_pagination.py (renamed from rest_framework/tests/test_pagination.py) | 3 | ||||
| -rw-r--r-- | tests/test_parsers.py (renamed from rest_framework/tests/test_parsers.py) | 0 | ||||
| -rw-r--r-- | tests/test_permissions.py (renamed from rest_framework/tests/test_permissions.py) | 15 | ||||
| -rw-r--r-- | tests/test_relations.py (renamed from rest_framework/tests/test_relations.py) | 4 | ||||
| -rw-r--r-- | tests/test_relations_hyperlink.py (renamed from rest_framework/tests/test_relations_hyperlink.py) | 12 | ||||
| -rw-r--r-- | tests/test_relations_nested.py (renamed from rest_framework/tests/test_relations_nested.py) | 0 | ||||
| -rw-r--r-- | tests/test_relations_pk.py (renamed from rest_framework/tests/test_relations_pk.py) | 2 | ||||
| -rw-r--r-- | tests/test_relations_slug.py (renamed from rest_framework/tests/test_relations_slug.py) | 2 | ||||
| -rw-r--r-- | tests/test_renderers.py (renamed from rest_framework/tests/test_renderers.py) | 6 | ||||
| -rw-r--r-- | tests/test_request.py (renamed from rest_framework/tests/test_request.py) | 2 | ||||
| -rw-r--r-- | tests/test_response.py (renamed from rest_framework/tests/test_response.py) | 10 | ||||
| -rw-r--r-- | tests/test_reverse.py (renamed from rest_framework/tests/test_reverse.py) | 2 | ||||
| -rw-r--r-- | tests/test_routers.py (renamed from rest_framework/tests/test_routers.py) | 4 | ||||
| -rw-r--r-- | tests/test_serializer.py (renamed from rest_framework/tests/test_serializer.py) | 6 | ||||
| -rw-r--r-- | tests/test_serializer_bulk_update.py (renamed from rest_framework/tests/test_serializer_bulk_update.py) | 0 | ||||
| -rw-r--r-- | tests/test_serializer_empty.py (renamed from rest_framework/tests/test_serializer_empty.py) | 0 | ||||
| -rw-r--r-- | tests/test_serializer_import.py (renamed from rest_framework/tests/test_serializer_import.py) | 2 | ||||
| -rw-r--r-- | tests/test_serializer_nested.py (renamed from rest_framework/tests/test_serializer_nested.py) | 0 | ||||
| -rw-r--r-- | tests/test_serializers.py (renamed from rest_framework/tests/test_serializers.py) | 2 | ||||
| -rw-r--r-- | tests/test_settings.py (renamed from rest_framework/tests/test_settings.py) | 4 | ||||
| -rw-r--r-- | tests/test_status.py (renamed from rest_framework/tests/test_status.py) | 0 | ||||
| -rw-r--r-- | tests/test_templatetags.py (renamed from rest_framework/tests/test_templatetags.py) | 0 | ||||
| -rw-r--r-- | tests/test_testing.py (renamed from rest_framework/tests/test_testing.py) | 2 | ||||
| -rw-r--r-- | tests/test_throttling.py (renamed from rest_framework/tests/test_throttling.py) | 0 | ||||
| -rw-r--r-- | tests/test_urlizer.py (renamed from rest_framework/tests/test_urlizer.py) | 0 | ||||
| -rw-r--r-- | tests/test_urlpatterns.py (renamed from rest_framework/tests/test_urlpatterns.py) | 0 | ||||
| -rw-r--r-- | tests/test_validation.py (renamed from rest_framework/tests/test_validation.py) | 0 | ||||
| -rw-r--r-- | tests/test_views.py (renamed from rest_framework/tests/test_views.py) | 0 | ||||
| -rw-r--r-- | tests/test_write_only_fields.py (renamed from rest_framework/tests/test_write_only_fields.py) | 0 | ||||
| -rw-r--r-- | tests/urls.py | 6 | ||||
| -rw-r--r-- | tests/users/__init__.py (renamed from rest_framework/tests/records/__init__.py) | 0 | ||||
| -rw-r--r-- | tests/users/models.py (renamed from rest_framework/tests/users/models.py) | 0 | ||||
| -rw-r--r-- | tests/users/serializers.py (renamed from rest_framework/tests/users/serializers.py) | 2 | ||||
| -rw-r--r-- | tests/utils.py (renamed from rest_framework/tests/utils.py) | 0 | ||||
| -rw-r--r-- | tests/views.py (renamed from rest_framework/tests/views.py) | 4 | ||||
| -rw-r--r-- | tox.ini | 14 | 
75 files changed, 205 insertions, 256 deletions
| diff --git a/.travis.yml b/.travis.yml index 60b48cba..13dc3e28 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ env:  install:    - pip install $DJANGO    - pip install defusedxml==0.3 Pillow==2.3.0 +  - pip install pytest-django==2.6    - "if [[ ${TRAVIS_PYTHON_VERSION::1} != '3' ]]; then pip install oauth2==1.5.211; fi"    - "if [[ ${TRAVIS_PYTHON_VERSION::1} != '3' ]]; then pip install django-oauth-plus==2.2.4; fi"    - "if [[ ${TRAVIS_PYTHON_VERSION::1} != '3' ]]; then pip install django-oauth2-provider==0.2.4; fi" @@ -27,7 +28,7 @@ install:    - export PYTHONPATH=.  script: -  - python rest_framework/runtests/runtests.py +  - py.test  matrix:    exclude: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a7aa6fc4..ff6018b8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,7 +65,7 @@ To run the tests, clone the repository, and then:      pip install -r optionals.txt      # Run the tests -    rest_framework/runtests/runtests.py +    py.test  You can also use the excellent [`tox`][tox] testing tool to run the tests against all supported versions of Python and Django.  Install `tox` globally, and then simply run: diff --git a/conftest.py b/conftest.py new file mode 100644 index 00000000..7cfc77f2 --- /dev/null +++ b/conftest.py @@ -0,0 +1,85 @@ +def pytest_configure(): +    from django.conf import settings + +    settings.configure( +        DEBUG_PROPAGATE_EXCEPTIONS=True, +        DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', +                               'NAME': ':memory:'}}, +        SECRET_KEY='not very secret in tests', +        USE_I18N=True, +        USE_L10N=True, +        STATIC_URL='/static/', +        ROOT_URLCONF='tests.urls', +        TEMPLATE_LOADERS=( +            'django.template.loaders.filesystem.Loader', +            'django.template.loaders.app_directories.Loader', +        ), +        MIDDLEWARE_CLASSES=( +            'django.middleware.common.CommonMiddleware', +            'django.contrib.sessions.middleware.SessionMiddleware', +            'django.middleware.csrf.CsrfViewMiddleware', +            'django.contrib.auth.middleware.AuthenticationMiddleware', +            'django.contrib.messages.middleware.MessageMiddleware', +        ), +        INSTALLED_APPS=( +            'django.contrib.auth', +            'django.contrib.contenttypes', +            'django.contrib.sessions', +            'django.contrib.sites', +            'django.contrib.messages', + +            'rest_framework', +            'rest_framework.authtoken', +            'tests', +            'tests.accounts', +            'tests.records', +            'tests.users', +        ), +        PASSWORD_HASHERS=( +            'django.contrib.auth.hashers.SHA1PasswordHasher', +            'django.contrib.auth.hashers.PBKDF2PasswordHasher', +            'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher', +            'django.contrib.auth.hashers.BCryptPasswordHasher', +            'django.contrib.auth.hashers.MD5PasswordHasher', +            'django.contrib.auth.hashers.CryptPasswordHasher', +        ), +    ) + +    try: +        import oauth_provider +        import oauth2 +    except ImportError: +        pass +    else: +        settings.INSTALLED_APPS += ( +            'oauth_provider', +        ) + +    try: +        import provider +    except ImportError: +        pass +    else: +        settings.INSTALLED_APPS += ( +            'provider', +            'provider.oauth2', +        ) + +    # guardian is optional +    try: +        import guardian +    except ImportError: +        pass +    else: +        settings.ANONYMOUS_USER_ID = -1 +        settings.AUTHENTICATION_BACKENDS = ( +            'django.contrib.auth.backends.ModelBackend', # default +            'guardian.backends.ObjectPermissionBackend', +        ) +        settings.INSTALLED_APPS += ( +            'guardian', +        ) + +    # Force Django to load all models +    from django.db.models import get_models +    get_models() diff --git a/docs/index.md b/docs/index.md index 2a4ad885..9ad647ac 100644 --- a/docs/index.md +++ b/docs/index.md @@ -206,19 +206,9 @@ General guides to using REST framework.  ## Development -If you want to work on REST framework itself, clone the repository, then... - -Build the docs: - -    ./mkdocs.py - -Run the tests: - -    ./rest_framework/runtests/runtests.py - -To run the tests against all supported configurations, first install [the tox testing tool][tox] globally, using `pip install tox`, then simply run `tox`: - -    tox +See the [Contribution guidelines][contributing] for information on how to clone +the repository, run the test suite and contribute changes back to REST +Framework.  ## Support diff --git a/docs/topics/contributing.md b/docs/topics/contributing.md index 18a05050..d33843e1 100644 --- a/docs/topics/contributing.md +++ b/docs/topics/contributing.md @@ -65,7 +65,7 @@ To run the tests, clone the repository, and then:      pip install -r optionals.txt      # Run the tests -    rest_framework/runtests/runtests.py +    py.test  You can also use the excellent [tox][tox] testing tool to run the tests against all supported versions of Python and Django.  Install `tox` globally, and then simply run: diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..bbd083ac --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --tb=short diff --git a/requirements.txt b/requirements.txt index 730c1d07..360acb14 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ +-e .  Django>=1.3 +pytest-django==2.6 diff --git a/rest_framework/runtests/runcoverage.py b/rest_framework/runtests/runcoverage.py deleted file mode 100755 index ce11b213..00000000 --- a/rest_framework/runtests/runcoverage.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python -""" -Useful tool to run the test suite for rest_framework and generate a coverage report. -""" - -# http://ericholscher.com/blog/2009/jun/29/enable-setuppy-test-your-django-apps/ -# http://www.travisswicegood.com/2010/01/17/django-virtualenv-pip-and-fabric/ -# http://code.djangoproject.com/svn/django/trunk/tests/runtests.py -import os -import sys - -# fix sys path so we don't need to setup PYTHONPATH -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -os.environ['DJANGO_SETTINGS_MODULE'] = 'rest_framework.runtests.settings' - -from coverage import coverage - - -def main(): -    """Run the tests for rest_framework and generate a coverage report.""" - -    cov = coverage() -    cov.erase() -    cov.start() - -    from django.conf import settings -    from django.test.utils import get_runner -    TestRunner = get_runner(settings) - -    if hasattr(TestRunner, 'func_name'): -        # Pre 1.2 test runners were just functions, -        # and did not support the 'failfast' option. -        import warnings -        warnings.warn( -            'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.', -            DeprecationWarning -        ) -        failures = TestRunner(['tests']) -    else: -        test_runner = TestRunner() -        failures = test_runner.run_tests(['tests']) -    cov.stop() - -    # Discover the list of all modules that we should test coverage for -    import rest_framework - -    project_dir = os.path.dirname(rest_framework.__file__) -    cov_files = [] - -    for (path, dirs, files) in os.walk(project_dir): -        # Drop tests and runtests directories from the test coverage report -        if os.path.basename(path) in ['tests', 'runtests', 'migrations']: -            continue - -        # Drop the compat and six modules from coverage, since we're not interested in the coverage -        # of modules which are specifically for resolving environment dependant imports. -        # (Because we'll end up getting different coverage reports for it for each environment) -        if 'compat.py' in files: -            files.remove('compat.py') - -        if 'six.py' in files: -            files.remove('six.py') - -        # Same applies to template tags module. -        # This module has to include branching on Django versions, -        # so it's never possible for it to have full coverage. -        if 'rest_framework.py' in files: -            files.remove('rest_framework.py') - -        cov_files.extend([os.path.join(path, file) for file in files if file.endswith('.py')]) - -    cov.report(cov_files) -    if '--html' in sys.argv: -        cov.html_report(cov_files, directory='coverage') -    sys.exit(failures) - -if __name__ == '__main__': -    main() diff --git a/rest_framework/runtests/runtests.py b/rest_framework/runtests/runtests.py deleted file mode 100755 index 2daaae4e..00000000 --- a/rest_framework/runtests/runtests.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python - -# http://ericholscher.com/blog/2009/jun/29/enable-setuppy-test-your-django-apps/ -# http://www.travisswicegood.com/2010/01/17/django-virtualenv-pip-and-fabric/ -# http://code.djangoproject.com/svn/django/trunk/tests/runtests.py -import os -import sys - -# fix sys path so we don't need to setup PYTHONPATH -sys.path.append(os.path.join(os.path.dirname(__file__), "../..")) -os.environ['DJANGO_SETTINGS_MODULE'] = 'rest_framework.runtests.settings' - -import django -from django.conf import settings -from django.test.utils import get_runner - - -def usage(): -    return """ -    Usage: python runtests.py [UnitTestClass].[method] - -    You can pass the Class name of the `UnitTestClass` you want to test. - -    Append a method name if you only want to test a specific method of that class. -    """ - - -def main(): -    try: -        django.setup() -    except AttributeError: -        pass -    TestRunner = get_runner(settings) - -    test_runner = TestRunner() -    if len(sys.argv) == 2: -        test_case = '.' + sys.argv[1] -    elif len(sys.argv) == 1: -        test_case = '' -    else: -        print(usage()) -        sys.exit(1) -    test_module_name = 'rest_framework.tests' -    if django.VERSION[0] == 1 and django.VERSION[1] < 6: -        test_module_name = 'tests' - -    failures = test_runner.run_tests([test_module_name + test_case]) - -    sys.exit(failures) - -if __name__ == '__main__': -    main() diff --git a/rest_framework/runtests/urls.py b/rest_framework/runtests/urls.py deleted file mode 100644 index ed5baeae..00000000 --- a/rest_framework/runtests/urls.py +++ /dev/null @@ -1,7 +0,0 @@ -""" -Blank URLConf just to keep runtests.py happy. -""" -from rest_framework.compat import patterns - -urlpatterns = patterns('', -) diff --git a/rest_framework/tests/tests.py b/rest_framework/tests/tests.py deleted file mode 100644 index 554ebd1a..00000000 --- a/rest_framework/tests/tests.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -Force import of all modules in this package in order to get the standard test -runner to pick up the tests.  Yowzers. -""" -from __future__ import unicode_literals -import os -import django - -modules = [filename.rsplit('.', 1)[0] -           for filename in os.listdir(os.path.dirname(__file__)) -           if filename.endswith('.py') and not filename.startswith('_')] -__test__ = dict() - -if django.VERSION < (1, 6): -    for module in modules: -        exec("from rest_framework.tests.%s import *" % module) diff --git a/rest_framework/tests/users/__init__.py b/rest_framework/tests/users/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/rest_framework/tests/users/__init__.py +++ /dev/null @@ -2,11 +2,26 @@  # -*- coding: utf-8 -*-  from setuptools import setup +from setuptools.command.test import test as TestCommand  import re  import os  import sys +# This command has been borrowed from +# https://github.com/getsentry/sentry/blob/master/setup.py +class PyTest(TestCommand): +    def finalize_options(self): +        TestCommand.finalize_options(self) +        self.test_args = ['tests'] +        self.test_suite = True + +    def run_tests(self): +        import pytest +        errno = pytest.main(self.test_args) +        sys.exit(errno) + +  def get_version(package):      """      Return package version as listed in `__version__` in `init.py`. @@ -62,7 +77,7 @@ setup(      author_email='tom@tomchristie.com',  # SEE NOTE BELOW (*)      packages=get_packages('rest_framework'),      package_data=get_package_data('rest_framework'), -    test_suite='rest_framework.runtests.runtests.main', +    cmdclass={'test': PyTest},      install_requires=[],      classifiers=[          'Development Status :: 5 - Production/Stable', diff --git a/rest_framework/runtests/__init__.py b/tests/__init__.py index e69de29b..e69de29b 100644 --- a/rest_framework/runtests/__init__.py +++ b/tests/__init__.py diff --git a/rest_framework/tests/__init__.py b/tests/accounts/__init__.py index e69de29b..e69de29b 100644 --- a/rest_framework/tests/__init__.py +++ b/tests/accounts/__init__.py diff --git a/rest_framework/tests/accounts/models.py b/tests/accounts/models.py index 525e601b..3bf4a0c3 100644 --- a/rest_framework/tests/accounts/models.py +++ b/tests/accounts/models.py @@ -1,6 +1,6 @@  from django.db import models -from rest_framework.tests.users.models import User +from tests.users.models import User  class Account(models.Model): diff --git a/rest_framework/tests/accounts/serializers.py b/tests/accounts/serializers.py index a27b9ca6..57a91b92 100644 --- a/rest_framework/tests/accounts/serializers.py +++ b/tests/accounts/serializers.py @@ -1,7 +1,7 @@  from rest_framework import serializers -from rest_framework.tests.accounts.models import Account -from rest_framework.tests.users.serializers import UserSerializer +from tests.accounts.models import Account +from tests.users.serializers import UserSerializer  class AccountSerializer(serializers.ModelSerializer): diff --git a/rest_framework/tests/description.py b/tests/description.py index b46d7f54..b46d7f54 100644 --- a/rest_framework/tests/description.py +++ b/tests/description.py diff --git a/rest_framework/tests/accounts/__init__.py b/tests/extras/__init__.py index e69de29b..e69de29b 100644 --- a/rest_framework/tests/accounts/__init__.py +++ b/tests/extras/__init__.py diff --git a/rest_framework/tests/extras/bad_import.py b/tests/extras/bad_import.py index 68263d94..68263d94 100644 --- a/rest_framework/tests/extras/bad_import.py +++ b/tests/extras/bad_import.py diff --git a/rest_framework/tests/models.py b/tests/models.py index 6c8f2342..6c8f2342 100644 --- a/rest_framework/tests/models.py +++ b/tests/models.py diff --git a/rest_framework/tests/extras/__init__.py b/tests/records/__init__.py index e69de29b..e69de29b 100644 --- a/rest_framework/tests/extras/__init__.py +++ b/tests/records/__init__.py diff --git a/rest_framework/tests/records/models.py b/tests/records/models.py index 76954807..76954807 100644 --- a/rest_framework/tests/records/models.py +++ b/tests/records/models.py diff --git a/rest_framework/tests/serializers.py b/tests/serializers.py index cc943c7d..f2f85b6e 100644 --- a/rest_framework/tests/serializers.py +++ b/tests/serializers.py @@ -1,6 +1,6 @@  from rest_framework import serializers -from rest_framework.tests.models import NullableForeignKeySource +from tests.models import NullableForeignKeySource  class NullableFKSourceSerializer(serializers.ModelSerializer): diff --git a/rest_framework/runtests/settings.py b/tests/settings.py index 3fc0eb2f..75f7c54b 100644 --- a/rest_framework/runtests/settings.py +++ b/tests/settings.py @@ -79,7 +79,7 @@ MIDDLEWARE_CLASSES = (      'django.contrib.messages.middleware.MessageMiddleware',  ) -ROOT_URLCONF = 'urls' +ROOT_URLCONF = 'tests.urls'  TEMPLATE_DIRS = (      # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". @@ -99,10 +99,10 @@ INSTALLED_APPS = (      # 'django.contrib.admindocs',      'rest_framework',      'rest_framework.authtoken', -    'rest_framework.tests', -    'rest_framework.tests.accounts', -    'rest_framework.tests.records', -    'rest_framework.tests.users', +    'tests', +    'tests.accounts', +    'tests.records', +    'tests.users',  )  # OAuth is optional and won't work if there is no oauth_provider & oauth2 diff --git a/rest_framework/tests/test_authentication.py b/tests/test_authentication.py index c37d2a51..1d90493e 100644 --- a/rest_framework/tests/test_authentication.py +++ b/tests/test_authentication.py @@ -69,7 +69,7 @@ if oauth2_provider is not None:  class BasicAuthTests(TestCase):      """Basic authentication""" -    urls = 'rest_framework.tests.test_authentication' +    urls = 'tests.test_authentication'      def setUp(self):          self.csrf_client = APIClient(enforce_csrf_checks=True) @@ -108,7 +108,7 @@ class BasicAuthTests(TestCase):  class SessionAuthTests(TestCase):      """User session authentication""" -    urls = 'rest_framework.tests.test_authentication' +    urls = 'tests.test_authentication'      def setUp(self):          self.csrf_client = APIClient(enforce_csrf_checks=True) @@ -155,7 +155,7 @@ class SessionAuthTests(TestCase):  class TokenAuthTests(TestCase):      """Token authentication""" -    urls = 'rest_framework.tests.test_authentication' +    urls = 'tests.test_authentication'      def setUp(self):          self.csrf_client = APIClient(enforce_csrf_checks=True) @@ -249,7 +249,7 @@ class IncorrectCredentialsTests(TestCase):  class OAuthTests(TestCase):      """OAuth 1.0a authentication""" -    urls = 'rest_framework.tests.test_authentication' +    urls = 'tests.test_authentication'      def setUp(self):          # these imports are here because oauth is optional and hiding them in try..except block or compat @@ -479,7 +479,7 @@ class OAuthTests(TestCase):  class OAuth2Tests(TestCase):      """OAuth 2.0 authentication""" -    urls = 'rest_framework.tests.test_authentication' +    urls = 'tests.test_authentication'      def setUp(self):          self.csrf_client = APIClient(enforce_csrf_checks=True) diff --git a/rest_framework/tests/test_breadcrumbs.py b/tests/test_breadcrumbs.py index 41ddf2ce..78edc603 100644 --- a/rest_framework/tests/test_breadcrumbs.py +++ b/tests/test_breadcrumbs.py @@ -36,7 +36,7 @@ urlpatterns = patterns('',  class BreadcrumbTests(TestCase):      """Tests the breadcrumb functionality used by the HTML renderer.""" -    urls = 'rest_framework.tests.test_breadcrumbs' +    urls = 'tests.test_breadcrumbs'      def test_root_breadcrumbs(self):          url = '/' diff --git a/rest_framework/tests/test_decorators.py b/tests/test_decorators.py index 195f0ba3..195f0ba3 100644 --- a/rest_framework/tests/test_decorators.py +++ b/tests/test_decorators.py diff --git a/rest_framework/tests/test_description.py b/tests/test_description.py index 4c03c1de..1e481f06 100644 --- a/rest_framework/tests/test_description.py +++ b/tests/test_description.py @@ -4,8 +4,8 @@ from __future__ import unicode_literals  from django.test import TestCase  from rest_framework.compat import apply_markdown, smart_text  from rest_framework.views import APIView -from rest_framework.tests.description import ViewWithNonASCIICharactersInDocstring -from rest_framework.tests.description import UTF8_TEST_DOCSTRING +from .description import ViewWithNonASCIICharactersInDocstring +from .description import UTF8_TEST_DOCSTRING  # We check that docstrings get nicely un-indented.  DESCRIPTION = """an example docstring diff --git a/rest_framework/tests/test_fields.py b/tests/test_fields.py index e127feef..e65a2fb3 100644 --- a/rest_framework/tests/test_fields.py +++ b/tests/test_fields.py @@ -11,7 +11,7 @@ from django.db import models  from django.test import TestCase  from django.utils.datastructures import SortedDict  from rest_framework import serializers -from rest_framework.tests.models import RESTFrameworkModel +from tests.models import RESTFrameworkModel  class TimestampedModel(models.Model): diff --git a/rest_framework/tests/test_files.py b/tests/test_files.py index 78f4cf42..78f4cf42 100644 --- a/rest_framework/tests/test_files.py +++ b/tests/test_files.py diff --git a/rest_framework/tests/test_filters.py b/tests/test_filters.py index 23226bbc..3c6e8857 100644 --- a/rest_framework/tests/test_filters.py +++ b/tests/test_filters.py @@ -9,8 +9,7 @@ from rest_framework import generics, serializers, status, filters  from rest_framework.compat import django_filters, patterns, url  from rest_framework.settings import api_settings  from rest_framework.test import APIRequestFactory -from rest_framework.tests.models import BasicModel -from .models import FilterableItem +from .models import FilterableItem, BasicModel  from .utils import temporary_setting  factory = APIRequestFactory() @@ -243,7 +242,7 @@ class IntegrationTestDetailFiltering(CommonFilteringTestCase):      """      Integration tests for filtered detail views.      """ -    urls = 'rest_framework.tests.test_filters' +    urls = 'tests.test_filters'      def _get_url(self, item):          return reverse('detail-view', kwargs=dict(pk=item.pk)) diff --git a/rest_framework/tests/test_genericrelations.py b/tests/test_genericrelations.py index 46a2d863..46a2d863 100644 --- a/rest_framework/tests/test_genericrelations.py +++ b/tests/test_genericrelations.py diff --git a/rest_framework/tests/test_generics.py b/tests/test_generics.py index 996bd5b0..4389994a 100644 --- a/rest_framework/tests/test_generics.py +++ b/tests/test_generics.py @@ -4,7 +4,7 @@ from django.shortcuts import get_object_or_404  from django.test import TestCase  from rest_framework import generics, renderers, serializers, status  from rest_framework.test import APIRequestFactory -from rest_framework.tests.models import BasicModel, Comment, SlugBasedModel +from tests.models import BasicModel, Comment, SlugBasedModel  from rest_framework.compat import six  factory = APIRequestFactory() diff --git a/rest_framework/tests/test_htmlrenderer.py b/tests/test_htmlrenderer.py index 514d9e2b..8af5bb50 100644 --- a/rest_framework/tests/test_htmlrenderer.py +++ b/tests/test_htmlrenderer.py @@ -42,7 +42,7 @@ urlpatterns = patterns('',  class TemplateHTMLRendererTests(TestCase): -    urls = 'rest_framework.tests.test_htmlrenderer' +    urls = 'tests.test_htmlrenderer'      def setUp(self):          """ @@ -82,7 +82,7 @@ class TemplateHTMLRendererTests(TestCase):  class TemplateHTMLRendererExceptionTests(TestCase): -    urls = 'rest_framework.tests.test_htmlrenderer' +    urls = 'tests.test_htmlrenderer'      def setUp(self):          """ diff --git a/rest_framework/tests/test_hyperlinkedserializers.py b/tests/test_hyperlinkedserializers.py index 83d46043..eee179ca 100644 --- a/rest_framework/tests/test_hyperlinkedserializers.py +++ b/tests/test_hyperlinkedserializers.py @@ -5,7 +5,7 @@ from rest_framework import generics, status, serializers  from rest_framework.compat import patterns, url  from rest_framework.settings import api_settings  from rest_framework.test import APIRequestFactory -from rest_framework.tests.models import ( +from tests.models import (      Anchor, BasicModel, ManyToManyModel, BlogPost, BlogPostComment,      Album, Photo, OptionalRelationModel  ) @@ -110,7 +110,7 @@ urlpatterns = patterns('',  class TestBasicHyperlinkedView(TestCase): -    urls = 'rest_framework.tests.test_hyperlinkedserializers' +    urls = 'tests.test_hyperlinkedserializers'      def setUp(self):          """ @@ -147,7 +147,7 @@ class TestBasicHyperlinkedView(TestCase):  class TestManyToManyHyperlinkedView(TestCase): -    urls = 'rest_framework.tests.test_hyperlinkedserializers' +    urls = 'tests.test_hyperlinkedserializers'      def setUp(self):          """ @@ -195,7 +195,7 @@ class TestManyToManyHyperlinkedView(TestCase):  class TestHyperlinkedIdentityFieldLookup(TestCase): -    urls = 'rest_framework.tests.test_hyperlinkedserializers' +    urls = 'tests.test_hyperlinkedserializers'      def setUp(self):          """ @@ -225,7 +225,7 @@ class TestHyperlinkedIdentityFieldLookup(TestCase):  class TestCreateWithForeignKeys(TestCase): -    urls = 'rest_framework.tests.test_hyperlinkedserializers' +    urls = 'tests.test_hyperlinkedserializers'      def setUp(self):          """ @@ -250,7 +250,7 @@ class TestCreateWithForeignKeys(TestCase):  class TestCreateWithForeignKeysAndCustomSlug(TestCase): -    urls = 'rest_framework.tests.test_hyperlinkedserializers' +    urls = 'tests.test_hyperlinkedserializers'      def setUp(self):          """ @@ -275,7 +275,7 @@ class TestCreateWithForeignKeysAndCustomSlug(TestCase):  class TestOptionalRelationHyperlinkedView(TestCase): -    urls = 'rest_framework.tests.test_hyperlinkedserializers' +    urls = 'tests.test_hyperlinkedserializers'      def setUp(self):          """ @@ -335,7 +335,7 @@ class TestOverriddenURLField(TestCase):  class TestURLFieldNameBySettings(TestCase): -    urls = 'rest_framework.tests.test_hyperlinkedserializers' +    urls = 'tests.test_hyperlinkedserializers'      def setUp(self):          self.saved_url_field_name = api_settings.URL_FIELD_NAME @@ -360,7 +360,7 @@ class TestURLFieldNameBySettings(TestCase):  class TestURLFieldNameByOptions(TestCase): -    urls = 'rest_framework.tests.test_hyperlinkedserializers' +    urls = 'tests.test_hyperlinkedserializers'      def setUp(self):          class Serializer(serializers.HyperlinkedModelSerializer): diff --git a/rest_framework/tests/test_multitable_inheritance.py b/tests/test_multitable_inheritance.py index 00c15327..ce1bf3ea 100644 --- a/rest_framework/tests/test_multitable_inheritance.py +++ b/tests/test_multitable_inheritance.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals  from django.db import models  from django.test import TestCase  from rest_framework import serializers -from rest_framework.tests.models import RESTFrameworkModel +from tests.models import RESTFrameworkModel  # Models diff --git a/rest_framework/tests/test_negotiation.py b/tests/test_negotiation.py index 04b89eb6..04b89eb6 100644 --- a/rest_framework/tests/test_negotiation.py +++ b/tests/test_negotiation.py diff --git a/rest_framework/tests/test_nullable_fields.py b/tests/test_nullable_fields.py index 6ee55c00..33a9685f 100644 --- a/rest_framework/tests/test_nullable_fields.py +++ b/tests/test_nullable_fields.py @@ -2,9 +2,9 @@ from django.core.urlresolvers import reverse  from rest_framework.compat import patterns, url  from rest_framework.test import APITestCase -from rest_framework.tests.models import NullableForeignKeySource -from rest_framework.tests.serializers import NullableFKSourceSerializer -from rest_framework.tests.views import NullableFKSourceDetail +from tests.models import NullableForeignKeySource +from tests.serializers import NullableFKSourceSerializer +from tests.views import NullableFKSourceDetail  urlpatterns = patterns( @@ -18,7 +18,7 @@ class NullableForeignKeyTests(APITestCase):      DRF should be able to handle nullable foreign keys when a test      Client POST/PUT request is made with its own serialized object.      """ -    urls = 'rest_framework.tests.test_nullable_fields' +    urls = 'tests.test_nullable_fields'      def test_updating_object_with_null_fk(self):          obj = NullableForeignKeySource(name='example', target=None) diff --git a/rest_framework/tests/test_pagination.py b/tests/test_pagination.py index 24c1ba39..293146c0 100644 --- a/rest_framework/tests/test_pagination.py +++ b/tests/test_pagination.py @@ -8,8 +8,7 @@ from django.utils import unittest  from rest_framework import generics, status, pagination, filters, serializers  from rest_framework.compat import django_filters  from rest_framework.test import APIRequestFactory -from rest_framework.tests.models import BasicModel -from .models import FilterableItem +from .models import BasicModel, FilterableItem  factory = APIRequestFactory() diff --git a/rest_framework/tests/test_parsers.py b/tests/test_parsers.py index 8af90677..8af90677 100644 --- a/rest_framework/tests/test_parsers.py +++ b/tests/test_parsers.py diff --git a/rest_framework/tests/test_permissions.py b/tests/test_permissions.py index 6e3a6303..a2cb0c36 100644 --- a/rest_framework/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -7,7 +7,7 @@ from rest_framework import generics, status, permissions, authentication, HTTP_H  from rest_framework.compat import guardian, get_model_name  from rest_framework.filters import DjangoObjectPermissionsFilter  from rest_framework.test import APIRequestFactory -from rest_framework.tests.models import BasicModel +from tests.models import BasicModel  import base64  factory = APIRequestFactory() @@ -187,8 +187,7 @@ class ObjectPermissionsIntegrationTests(TestCase):      """      Integration tests for the object level permissions API.      """ -    @classmethod -    def setUpClass(cls): +    def setUp(self):          from guardian.shortcuts import assign_perm          # create users @@ -215,21 +214,13 @@ class ObjectPermissionsIntegrationTests(TestCase):              assign_perm(perm, everyone)          everyone.user_set.add(*users.values()) -        cls.perms = perms -        cls.users = users - -    def setUp(self): -        from guardian.shortcuts import assign_perm -        perms = self.perms -        users = self.users -          # appropriate object level permissions          readers = Group.objects.create(name='readers')          writers = Group.objects.create(name='writers')          deleters = Group.objects.create(name='deleters')          model = BasicPermModel.objects.create(text='foo') -         +          assign_perm(perms['view'], readers, model)          assign_perm(perms['change'], writers, model)          assign_perm(perms['delete'], deleters, model) diff --git a/rest_framework/tests/test_relations.py b/tests/test_relations.py index 37ac826b..cd276d30 100644 --- a/rest_framework/tests/test_relations.py +++ b/tests/test_relations.py @@ -7,7 +7,7 @@ from django.db import models  from django.test import TestCase  from django.utils import unittest  from rest_framework import serializers -from rest_framework.tests.models import BlogPost +from tests.models import BlogPost  class NullModel(models.Model): @@ -107,7 +107,7 @@ class RelatedFieldSourceTests(TestCase):          Check that the exception message are correct if the source field          doesn't exist.          """ -        from rest_framework.tests.models import ManyToManySource +        from tests.models import ManyToManySource          class Meta:              model = ManyToManySource          attrs = { diff --git a/rest_framework/tests/test_relations_hyperlink.py b/tests/test_relations_hyperlink.py index 3c4d39af..98f68d29 100644 --- a/rest_framework/tests/test_relations_hyperlink.py +++ b/tests/test_relations_hyperlink.py @@ -3,7 +3,7 @@ from django.test import TestCase  from rest_framework import serializers  from rest_framework.compat import patterns, url  from rest_framework.test import APIRequestFactory -from rest_framework.tests.models import ( +from tests.models import (      BlogPost,      ManyToManyTarget, ManyToManySource, ForeignKeyTarget, ForeignKeySource,      NullableForeignKeySource, OneToOneTarget, NullableOneToOneSource @@ -71,7 +71,7 @@ class NullableOneToOneTargetSerializer(serializers.HyperlinkedModelSerializer):  # TODO: Add test that .data cannot be accessed prior to .is_valid  class HyperlinkedManyToManyTests(TestCase): -    urls = 'rest_framework.tests.test_relations_hyperlink' +    urls = 'tests.test_relations_hyperlink'      def setUp(self):          for idx in range(1, 4): @@ -179,7 +179,7 @@ class HyperlinkedManyToManyTests(TestCase):  class HyperlinkedForeignKeyTests(TestCase): -    urls = 'rest_framework.tests.test_relations_hyperlink' +    urls = 'tests.test_relations_hyperlink'      def setUp(self):          target = ForeignKeyTarget(name='target-1') @@ -307,7 +307,7 @@ class HyperlinkedForeignKeyTests(TestCase):  class HyperlinkedNullableForeignKeyTests(TestCase): -    urls = 'rest_framework.tests.test_relations_hyperlink' +    urls = 'tests.test_relations_hyperlink'      def setUp(self):          target = ForeignKeyTarget(name='target-1') @@ -435,7 +435,7 @@ class HyperlinkedNullableForeignKeyTests(TestCase):  class HyperlinkedNullableOneToOneTests(TestCase): -    urls = 'rest_framework.tests.test_relations_hyperlink' +    urls = 'tests.test_relations_hyperlink'      def setUp(self):          target = OneToOneTarget(name='target-1') @@ -458,7 +458,7 @@ class HyperlinkedNullableOneToOneTests(TestCase):  # Regression tests for #694 (`source` attribute on related fields)  class HyperlinkedRelatedFieldSourceTests(TestCase): -    urls = 'rest_framework.tests.test_relations_hyperlink' +    urls = 'tests.test_relations_hyperlink'      def test_related_manager_source(self):          """ diff --git a/rest_framework/tests/test_relations_nested.py b/tests/test_relations_nested.py index 4d9da489..4d9da489 100644 --- a/rest_framework/tests/test_relations_nested.py +++ b/tests/test_relations_nested.py diff --git a/rest_framework/tests/test_relations_pk.py b/tests/test_relations_pk.py index 3815afdd..ff59b250 100644 --- a/rest_framework/tests/test_relations_pk.py +++ b/tests/test_relations_pk.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals  from django.db import models  from django.test import TestCase  from rest_framework import serializers -from rest_framework.tests.models import ( +from tests.models import (      BlogPost, ManyToManyTarget, ManyToManySource, ForeignKeyTarget, ForeignKeySource,      NullableForeignKeySource, OneToOneTarget, NullableOneToOneSource,  ) diff --git a/rest_framework/tests/test_relations_slug.py b/tests/test_relations_slug.py index 435c821c..97ebf23a 100644 --- a/rest_framework/tests/test_relations_slug.py +++ b/tests/test_relations_slug.py @@ -1,6 +1,6 @@  from django.test import TestCase  from rest_framework import serializers -from rest_framework.tests.models import NullableForeignKeySource, ForeignKeySource, ForeignKeyTarget +from tests.models import NullableForeignKeySource, ForeignKeySource, ForeignKeyTarget  class ForeignKeyTargetSerializer(serializers.ModelSerializer): diff --git a/rest_framework/tests/test_renderers.py b/tests/test_renderers.py index 7cb7d0f9..f733d6b6 100644 --- a/rest_framework/tests/test_renderers.py +++ b/tests/test_renderers.py @@ -152,7 +152,7 @@ class RendererEndToEndTests(TestCase):      End-to-end testing of renderers using an RendererMixin on a generic view.      """ -    urls = 'rest_framework.tests.test_renderers' +    urls = 'tests.test_renderers'      def test_default_renderer_serializes_content(self):          """If the Accept header is not set the default renderer should serialize the response.""" @@ -387,7 +387,7 @@ class JSONPRendererTests(TestCase):      Tests specific to the JSONP Renderer      """ -    urls = 'rest_framework.tests.test_renderers' +    urls = 'tests.test_renderers'      def test_without_callback_with_json_renderer(self):          """ @@ -582,7 +582,7 @@ class CacheRenderTest(TestCase):      Tests specific to caching responses      """ -    urls = 'rest_framework.tests.test_renderers' +    urls = 'tests.test_renderers'      cache_key = 'just_a_cache_key' diff --git a/rest_framework/tests/test_request.py b/tests/test_request.py index c0b50f33..0a9355f0 100644 --- a/rest_framework/tests/test_request.py +++ b/tests/test_request.py @@ -278,7 +278,7 @@ urlpatterns = patterns('',  class TestContentParsingWithAuthentication(TestCase): -    urls = 'rest_framework.tests.test_request' +    urls = 'tests.test_request'      def setUp(self):          self.csrf_client = APIClient(enforce_csrf_checks=True) diff --git a/rest_framework/tests/test_response.py b/tests/test_response.py index eea3c641..41c0f49d 100644 --- a/rest_framework/tests/test_response.py +++ b/tests/test_response.py @@ -1,6 +1,6 @@  from __future__ import unicode_literals  from django.test import TestCase -from rest_framework.tests.models import BasicModel, BasicModelSerializer +from tests.models import BasicModel, BasicModelSerializer  from rest_framework.compat import patterns, url, include  from rest_framework.response import Response  from rest_framework.views import APIView @@ -118,7 +118,7 @@ class RendererIntegrationTests(TestCase):      End-to-end testing of renderers using an ResponseMixin on a generic view.      """ -    urls = 'rest_framework.tests.test_response' +    urls = 'tests.test_response'      def test_default_renderer_serializes_content(self):          """If the Accept header is not set the default renderer should serialize the response.""" @@ -198,7 +198,7 @@ class Issue122Tests(TestCase):      """      Tests that covers #122.      """ -    urls = 'rest_framework.tests.test_response' +    urls = 'tests.test_response'      def test_only_html_renderer(self):          """ @@ -218,7 +218,7 @@ class Issue467Tests(TestCase):      Tests for #467      """ -    urls = 'rest_framework.tests.test_response' +    urls = 'tests.test_response'      def test_form_has_label_and_help_text(self):          resp = self.client.get('/html_new_model') @@ -232,7 +232,7 @@ class Issue807Tests(TestCase):      Covers #807      """ -    urls = 'rest_framework.tests.test_response' +    urls = 'tests.test_response'      def test_does_not_append_charset_by_default(self):          """ diff --git a/rest_framework/tests/test_reverse.py b/tests/test_reverse.py index 690a30b1..3d14a28f 100644 --- a/rest_framework/tests/test_reverse.py +++ b/tests/test_reverse.py @@ -19,7 +19,7 @@ class ReverseTests(TestCase):      """      Tests for fully qualified URLs when using `reverse`.      """ -    urls = 'rest_framework.tests.test_reverse' +    urls = 'tests.test_reverse'      def test_reversed_urls_are_fully_qualified(self):          request = factory.get('/view') diff --git a/rest_framework/tests/test_routers.py b/tests/test_routers.py index e723f7d4..084c0e27 100644 --- a/rest_framework/tests/test_routers.py +++ b/tests/test_routers.py @@ -72,7 +72,7 @@ class TestCustomLookupFields(TestCase):      """      Ensure that custom lookup fields are correctly routed.      """ -    urls = 'rest_framework.tests.test_routers' +    urls = 'tests.test_routers'      def setUp(self):          class NoteSerializer(serializers.HyperlinkedModelSerializer): @@ -91,7 +91,7 @@ class TestCustomLookupFields(TestCase):          self.router = SimpleRouter()          self.router.register(r'notes', NoteViewSet) -        from rest_framework.tests import test_routers +        from tests import test_routers          urls = getattr(test_routers, 'urlpatterns')          urls += patterns('',              url(r'^', include(self.router.urls)), diff --git a/rest_framework/tests/test_serializer.py b/tests/test_serializer.py index 3ee2b38a..f8966886 100644 --- a/rest_framework/tests/test_serializer.py +++ b/tests/test_serializer.py @@ -7,10 +7,10 @@ from django.utils import unittest  from django.utils.datastructures import MultiValueDict  from django.utils.translation import ugettext_lazy as _  from rest_framework import serializers, fields, relations -from rest_framework.tests.models import (HasPositiveIntegerAsChoice, Album, ActionItem, Anchor, BasicModel, +from tests.models import (HasPositiveIntegerAsChoice, Album, ActionItem, Anchor, BasicModel,      BlankFieldModel, BlogPost, BlogPostComment, Book, CallableDefaultValueModel, DefaultValueModel,      ManyToManyModel, Person, ReadOnlyManyToManyModel, Photo, RESTFrameworkModel) -from rest_framework.tests.models import BasicModelSerializer +from tests.models import BasicModelSerializer  import datetime  import pickle  try: @@ -1141,7 +1141,7 @@ class RelatedTraversalTest(TestCase):          """          If a component of the dotted.source is None, return None for the field.          """ -        from rest_framework.tests.models import NullableForeignKeySource +        from tests.models import NullableForeignKeySource          instance = NullableForeignKeySource.objects.create(name='Source with null FK')          class NullableSourceSerializer(serializers.Serializer): diff --git a/rest_framework/tests/test_serializer_bulk_update.py b/tests/test_serializer_bulk_update.py index 8b0ded1a..8b0ded1a 100644 --- a/rest_framework/tests/test_serializer_bulk_update.py +++ b/tests/test_serializer_bulk_update.py diff --git a/rest_framework/tests/test_serializer_empty.py b/tests/test_serializer_empty.py index 30cff361..30cff361 100644 --- a/rest_framework/tests/test_serializer_empty.py +++ b/tests/test_serializer_empty.py diff --git a/rest_framework/tests/test_serializer_import.py b/tests/test_serializer_import.py index 9f30a7ff..3b8ff4b3 100644 --- a/rest_framework/tests/test_serializer_import.py +++ b/tests/test_serializer_import.py @@ -1,7 +1,7 @@  from django.test import TestCase  from rest_framework import serializers -from rest_framework.tests.accounts.serializers import AccountSerializer +from tests.accounts.serializers import AccountSerializer  class ImportingModelSerializerTests(TestCase): diff --git a/rest_framework/tests/test_serializer_nested.py b/tests/test_serializer_nested.py index 6d69ffbd..6d69ffbd 100644 --- a/rest_framework/tests/test_serializer_nested.py +++ b/tests/test_serializer_nested.py diff --git a/rest_framework/tests/test_serializers.py b/tests/test_serializers.py index 082a400c..67547783 100644 --- a/rest_framework/tests/test_serializers.py +++ b/tests/test_serializers.py @@ -2,7 +2,7 @@ from django.db import models  from django.test import TestCase  from rest_framework.serializers import _resolve_model -from rest_framework.tests.models import BasicModel +from tests.models import BasicModel  class ResolveModelTests(TestCase): diff --git a/rest_framework/tests/test_settings.py b/tests/test_settings.py index 857375c2..e29fc34a 100644 --- a/rest_framework/tests/test_settings.py +++ b/tests/test_settings.py @@ -10,13 +10,13 @@ class TestSettings(TestCase):      def test_non_import_errors(self):          """Make sure other errors aren't suppressed.""" -        settings = APISettings({'DEFAULT_MODEL_SERIALIZER_CLASS': 'rest_framework.tests.extras.bad_import.ModelSerializer'}, DEFAULTS, IMPORT_STRINGS) +        settings = APISettings({'DEFAULT_MODEL_SERIALIZER_CLASS': 'tests.extras.bad_import.ModelSerializer'}, DEFAULTS, IMPORT_STRINGS)          with self.assertRaises(ValueError):              settings.DEFAULT_MODEL_SERIALIZER_CLASS      def test_import_error_message_maintained(self):          """Make sure real import errors are captured and raised sensibly.""" -        settings = APISettings({'DEFAULT_MODEL_SERIALIZER_CLASS': 'rest_framework.tests.extras.not_here.ModelSerializer'}, DEFAULTS, IMPORT_STRINGS) +        settings = APISettings({'DEFAULT_MODEL_SERIALIZER_CLASS': 'tests.extras.not_here.ModelSerializer'}, DEFAULTS, IMPORT_STRINGS)          with self.assertRaises(ImportError) as cm:              settings.DEFAULT_MODEL_SERIALIZER_CLASS          self.assertTrue('ImportError' in str(cm.exception)) diff --git a/rest_framework/tests/test_status.py b/tests/test_status.py index 7b1bdae3..7b1bdae3 100644 --- a/rest_framework/tests/test_status.py +++ b/tests/test_status.py diff --git a/rest_framework/tests/test_templatetags.py b/tests/test_templatetags.py index d4da0c23..d4da0c23 100644 --- a/rest_framework/tests/test_templatetags.py +++ b/tests/test_templatetags.py diff --git a/rest_framework/tests/test_testing.py b/tests/test_testing.py index a55d4b22..bd3e1329 100644 --- a/rest_framework/tests/test_testing.py +++ b/tests/test_testing.py @@ -35,7 +35,7 @@ urlpatterns = patterns('',  class TestAPITestClient(TestCase): -    urls = 'rest_framework.tests.test_testing' +    urls = 'tests.test_testing'      def setUp(self):          self.client = APIClient() diff --git a/rest_framework/tests/test_throttling.py b/tests/test_throttling.py index 41bff692..41bff692 100644 --- a/rest_framework/tests/test_throttling.py +++ b/tests/test_throttling.py diff --git a/rest_framework/tests/test_urlizer.py b/tests/test_urlizer.py index 3dc8e8fe..3dc8e8fe 100644 --- a/rest_framework/tests/test_urlizer.py +++ b/tests/test_urlizer.py diff --git a/rest_framework/tests/test_urlpatterns.py b/tests/test_urlpatterns.py index 8132ec4c..8132ec4c 100644 --- a/rest_framework/tests/test_urlpatterns.py +++ b/tests/test_urlpatterns.py diff --git a/rest_framework/tests/test_validation.py b/tests/test_validation.py index e13e4078..e13e4078 100644 --- a/rest_framework/tests/test_validation.py +++ b/tests/test_validation.py diff --git a/rest_framework/tests/test_views.py b/tests/test_views.py index 65c7e50e..65c7e50e 100644 --- a/rest_framework/tests/test_views.py +++ b/tests/test_views.py diff --git a/rest_framework/tests/test_write_only_fields.py b/tests/test_write_only_fields.py index aabb18d6..aabb18d6 100644 --- a/rest_framework/tests/test_write_only_fields.py +++ b/tests/test_write_only_fields.py diff --git a/tests/urls.py b/tests/urls.py new file mode 100644 index 00000000..62cad339 --- /dev/null +++ b/tests/urls.py @@ -0,0 +1,6 @@ +""" +Blank URLConf just to keep the test suite happy +""" +from rest_framework.compat import patterns + +urlpatterns = patterns('') diff --git a/rest_framework/tests/records/__init__.py b/tests/users/__init__.py index e69de29b..e69de29b 100644 --- a/rest_framework/tests/records/__init__.py +++ b/tests/users/__init__.py diff --git a/rest_framework/tests/users/models.py b/tests/users/models.py index 128bac90..128bac90 100644 --- a/rest_framework/tests/users/models.py +++ b/tests/users/models.py diff --git a/rest_framework/tests/users/serializers.py b/tests/users/serializers.py index da496554..4893ddb3 100644 --- a/rest_framework/tests/users/serializers.py +++ b/tests/users/serializers.py @@ -1,6 +1,6 @@  from rest_framework import serializers -from rest_framework.tests.users.models import User +from tests.users.models import User  class UserSerializer(serializers.ModelSerializer): diff --git a/rest_framework/tests/utils.py b/tests/utils.py index a8f2eb0b..a8f2eb0b 100644 --- a/rest_framework/tests/utils.py +++ b/tests/utils.py diff --git a/rest_framework/tests/views.py b/tests/views.py index 3917b74a..55935e92 100644 --- a/rest_framework/tests/views.py +++ b/tests/views.py @@ -1,6 +1,6 @@  from rest_framework import generics -from rest_framework.tests.models import NullableForeignKeySource -from rest_framework.tests.serializers import NullableFKSourceSerializer +from .models import NullableForeignKeySource +from .serializers import NullableFKSourceSerializer  class NullableFKSourceDetail(generics.RetrieveUpdateDestroyAPIView): @@ -3,7 +3,7 @@ downloadcache = {toxworkdir}/cache/  envlist = py3.3-django1.7,py3.2-django1.7,py2.7-django1.7,py3.3-django1.6,py3.2-django1.6,py2.7-django1.6,py2.6-django1.6,py3.3-django1.5,py3.2-django1.5,py2.7-django1.5,py2.6-django1.5,py2.7-django1.4,py2.6-django1.4,py2.7-django1.3,py2.6-django1.3  [testenv] -commands = {envpython} rest_framework/runtests/runtests.py +commands = py.test -q  [testenv:py3.3-django1.7]  basepython = python3.3 @@ -36,6 +36,7 @@ deps = Django==1.6         django-filter==0.7         defusedxml==0.3         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py3.2-django1.6]  basepython = python3.2 @@ -43,6 +44,7 @@ deps = Django==1.6         django-filter==0.7         defusedxml==0.3         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py2.7-django1.6]  basepython = python2.7 @@ -54,6 +56,7 @@ deps = Django==1.6         django-oauth2-provider==0.2.4         django-guardian==1.1.1         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py2.6-django1.6]  basepython = python2.6 @@ -65,6 +68,7 @@ deps = Django==1.6         django-oauth2-provider==0.2.4         django-guardian==1.1.1         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py3.3-django1.5]  basepython = python3.3 @@ -72,6 +76,7 @@ deps = django==1.5.5         django-filter==0.7         defusedxml==0.3         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py3.2-django1.5]  basepython = python3.2 @@ -79,6 +84,7 @@ deps = django==1.5.5         django-filter==0.7         defusedxml==0.3         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py2.7-django1.5]  basepython = python2.7 @@ -90,6 +96,7 @@ deps = django==1.5.5         django-oauth2-provider==0.2.3         django-guardian==1.1.1         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py2.6-django1.5]  basepython = python2.6 @@ -101,6 +108,7 @@ deps = django==1.5.5         django-oauth2-provider==0.2.3         django-guardian==1.1.1         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py2.7-django1.4]  basepython = python2.7 @@ -112,6 +120,7 @@ deps = django==1.4.10         django-oauth2-provider==0.2.3         django-guardian==1.1.1         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py2.6-django1.4]  basepython = python2.6 @@ -123,6 +132,7 @@ deps = django==1.4.10         django-oauth2-provider==0.2.3         django-guardian==1.1.1         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py2.7-django1.3]  basepython = python2.7 @@ -134,6 +144,7 @@ deps = django==1.3.5         django-oauth2-provider==0.2.3         django-guardian==1.1.1         Pillow==2.3.0 +       pytest-django==2.6  [testenv:py2.6-django1.3]  basepython = python2.6 @@ -145,3 +156,4 @@ deps = django==1.3.5         django-oauth2-provider==0.2.3         django-guardian==1.1.1         Pillow==2.3.0 +       pytest-django==2.6 | 
