Skip to content

Commit

Permalink
faster tests with django_nose.FastFixtureTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
magopian committed Nov 27, 2014
1 parent 70acd70 commit fe7cbd7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions apps/amo/runner.py
Expand Up @@ -4,10 +4,9 @@
import django_nose


class DiscoverRunnerWithExtraApps(django_nose.NoseTestSuiteRunner):
class TestRunner(django_nose.NoseTestSuiteRunner):
def setup_test_environment(self, **kwargs):
rval = super(
DiscoverRunnerWithExtraApps, self).setup_test_environment(**kwargs)
rval = super(TestRunner, self).setup_test_environment(**kwargs)
extra_apps = getattr(settings, 'TEST_INSTALLED_APPS')
if extra_apps:
installed_apps = getattr(settings, 'INSTALLED_APPS')
Expand Down
5 changes: 4 additions & 1 deletion apps/amo/tests/__init__.py
Expand Up @@ -23,6 +23,7 @@
import mock
import tower
from dateutil.parser import parse as dateutil_parser
from django_nose import FastFixtureTestCase
from nose.exc import SkipTest
from nose.tools import eq_, nottest
from pyquery import PyQuery as pq
Expand Down Expand Up @@ -258,7 +259,7 @@ def default_prefixer():
amo.urlresolvers.set_url_prefix(prefixer)


class BaseTestCase(test.TestCase):
class BaseTestCase(FastFixtureTestCase):
"""Base test case that each and every test cases should inherit from."""

def _pre_setup(self):
Expand Down Expand Up @@ -303,6 +304,8 @@ def instrumented_render(self, *args, **kwargs):
# Reset the prefixer.
default_prefixer()

self.client = self.client_class()

def _post_teardown(self):
amo.set_user(None)
clean_translations(None) # Make sure queued translations are removed.
Expand Down
4 changes: 2 additions & 2 deletions lib/settings_base.py
Expand Up @@ -423,13 +423,13 @@ def JINJA_CONFIG():
)

# These apps are only needed in a testing environment. They are added to
# INSTALLED_APPS by the RadicalTestSuiteRunnerWithExtraApps test runner.
# INSTALLED_APPS by the amo.runner.TestRunner test runner.
TEST_INSTALLED_APPS = (
'translations.tests.testapp',
)

# Tests
TEST_RUNNER = 'amo.runner.DiscoverRunnerWithExtraApps'
TEST_RUNNER = 'amo.runner.TestRunner'
NOSE_ARGS = [
'--with-fixture-bundling',
]
Expand Down

0 comments on commit fe7cbd7

Please sign in to comment.