コード例 #1
0
ファイル: test_django.py プロジェクト: K0den/webassets
    def setup(self):
        test_instance = self

        class MockBundle(Bundle):
            urls_to_fake = ["foo"]

            def __init__(self, *a, **kw):
                Bundle.__init__(self, *a, **kw)
                self.env = get_env()
                # Kind of hacky, but gives us access to the last Bundle
                # instance used by our Django template tag.
                test_instance.the_bundle = self

            def urls(self, *a, **kw):
                return self.urls_to_fake

        # Inject our mock bundle class
        self._old_bundle_class = AssetsNode.BundleClass
        AssetsNode.BundleClass = self.BundleClass = MockBundle

        # Reset the Django asset environment, init it with some
        # dummy bundles.
        django_env_reset()
        self.foo_bundle = Bundle()
        self.bar_bundle = Bundle()
        django_env_register("foo_bundle", self.foo_bundle)
        django_env_register("bar_bundle", self.bar_bundle)
コード例 #2
0
    def setup(self):
        test_instance = self

        class MockBundle(Bundle):
            urls_to_fake = ['foo']

            def __init__(self, *a, **kw):
                Bundle.__init__(self, *a, **kw)
                self.env = get_env()
                # Kind of hacky, but gives us access to the last Bundle
                # instance used by our Django template tag.
                test_instance.the_bundle = self

            def urls(self, *a, **kw):
                return self.urls_to_fake

        # Inject our mock bundle class
        self._old_bundle_class = AssetsNode.BundleClass
        AssetsNode.BundleClass = self.BundleClass = MockBundle

        # Reset the Django asset environment, init it with some
        # dummy bundles.
        django_env_reset()
        self.foo_bundle = Bundle()
        self.bar_bundle = Bundle()
        django_env_register('foo_bundle', self.foo_bundle)
        django_env_register('bar_bundle', self.bar_bundle)
コード例 #3
0
ファイル: test_django.py プロジェクト: holdenmatt/webassets
    def setup(self):
        TempDirHelper.setup(self)

        # Reset the webassets environment.
        django_env_reset()
        self.m = get_env()

        # Use a temporary directory as MEDIA_ROOT
        settings.MEDIA_ROOT = self.create_directories('media')[0]

        # Some other settings without which we are likely to run
        # into errors being raised as part of validation.
        setattr(settings, 'DATABASES', {})
        settings.DATABASES['default'] = {'ENGINE': ''}

        # Unless we explicitly test it, we don't want to use
        # the cache during testing.
        self.m.cache = False
コード例 #4
0
ファイル: test_django.py プロジェクト: grunskis/webassets
    def setup(self):
        TempDirHelper.setup(self)

        # Reset the webassets environment.
        django_env_reset()
        self.m = get_env()

        # Use a temporary directory as MEDIA_ROOT
        settings.MEDIA_ROOT = self.create_directories('media')[0]

        # Some other settings without which we are likely to run
        # into errors being raised as part of validation.
        setattr(settings, 'DATABASES', {})
        settings.DATABASES['default'] = {'ENGINE': ''}

        # Unless we explicitly test it, we don't want to use
        # the cache during testing.
        self.m.cache = False
コード例 #5
0
ファイル: test_django.py プロジェクト: K0den/webassets
    def setup(self):
        TempDirHelper.setup(self)

        # Reset the webassets environment.
        django_env_reset()
        self.env = get_env()

        # Use a temporary directory as MEDIA_ROOT
        settings.MEDIA_ROOT = self.create_directories("media")[0]

        # Some other settings without which we are likely to run
        # into errors being raised as part of validation.
        setattr(settings, "DATABASES", {})
        settings.DATABASES["default"] = {"ENGINE": ""}

        # Unless we explicitly test it, we don't want to use the cache during
        # testing.
        self.env.cache = False
        self.env.manifest = False
コード例 #6
0
ファイル: test_django.py プロジェクト: tilgovi/webassets
    def test_deprecated_options(self):
        try:
            django_env_reset()
            with check_warnings(("", ImminentDeprecationWarning)) as w:
                settings.ASSETS_EXPIRE = 'filename'
                assert_raises(DeprecationWarning, get_env)

            django_env_reset()
            with check_warnings(("", ImminentDeprecationWarning)) as w:
                settings.ASSETS_EXPIRE = 'querystring'
                assert get_env().url_expire == True

            with check_warnings(("", ImminentDeprecationWarning)) as w:
                django_env_reset()
                settings.ASSETS_UPDATER = 'never'
                assert get_env().auto_build == False
        finally:
            delsetting('ASSETS_EXPIRE')
            delsetting('ASSETS_UPDATER')
コード例 #7
0
ファイル: test_django.py プロジェクト: AshishNamdev/verbatim
    def test_deprecated_options(self):
        try:
            django_env_reset()
            with check_warnings(("", ImminentDeprecationWarning)) as w:
                settings.ASSETS_EXPIRE = 'filename'
                assert_raises(DeprecationWarning, get_env)

            django_env_reset()
            with check_warnings(("", ImminentDeprecationWarning)) as w:
                settings.ASSETS_EXPIRE = 'querystring'
                assert get_env().url_expire == True

            with check_warnings(("", ImminentDeprecationWarning)) as w:
                django_env_reset()
                settings.ASSETS_UPDATER = 'never'
                assert get_env().auto_build == False
        finally:
            delsetting('ASSETS_EXPIRE')
            delsetting('ASSETS_UPDATER')