コード例 #1
0
 def test_load_overlong_key(self):
     warnings_state = get_warnings_state()
     warnings.filterwarnings('ignore',
                             category=CacheKeyWarning)
     self.session._session_key = (string.ascii_letters + string.digits) * 20
     self.assertEqual(self.session.load(), {})
     restore_warnings_state(warnings_state)
コード例 #2
0
ファイル: tests.py プロジェクト: 15580056814/hue
 def test_load_overlong_key(self):
     warnings_state = get_warnings_state()
     warnings.filterwarnings('ignore',
                             category=CacheKeyWarning)
     self.session._session_key = (string.ascii_letters + string.digits) * 20
     self.assertEqual(self.session.load(), {})
     restore_warnings_state(warnings_state)
コード例 #3
0
ファイル: tests.py プロジェクト: atizo/django
    def test_invalid_keys(self):
        """
        All the builtin backends (except memcached, see below) should warn on
        keys that would be refused by memcached. This encourages portable
        caching code without making it too difficult to use production backends
        with more liberal key rules. Refs #6447.

        """
        # mimic custom ``make_key`` method being defined since the default will
        # never show the below warnings
        def func(key, *args):
            return key

        old_func = self.cache.key_func
        self.cache.key_func = func
        # On Python 2.6+ we could use the catch_warnings context
        # manager to test this warning nicely. Since we can't do that
        # yet, the cleanest option is to temporarily ask for
        # CacheKeyWarning to be raised as an exception.
        _warnings_state = get_warnings_state()
        warnings.simplefilter("error", CacheKeyWarning)

        try:
            # memcached does not allow whitespace or control characters in keys
            self.assertRaises(CacheKeyWarning, self.cache.set, 'key with spaces', 'value')
            # memcached limits key length to 250
            self.assertRaises(CacheKeyWarning, self.cache.set, 'a' * 251, 'value')
        finally:
            restore_warnings_state(_warnings_state)
            self.cache.key_func = old_func
コード例 #4
0
 def setUp(self):
     self._warnings_state = get_warnings_state()
     warnings.filterwarnings("ignore",
                             category=DeprecationWarning,
                             module='django.contrib.syndication.views')
     warnings.filterwarnings("ignore",
                             category=DeprecationWarning,
                             module='django.contrib.syndication.feeds')
コード例 #5
0
ファイル: loaders.py プロジェクト: 0xmilk/appscale
    def setUp(self):
        pkg_resources._provider_factories[MockLoader] = MockProvider

        self.empty_egg = create_egg("egg_empty", {})
        self.egg_1 = create_egg("egg_1", {
            os.path.normcase('templates/y.html') : StringIO.StringIO("y"),
            os.path.normcase('templates/x.txt') : StringIO.StringIO("x"),
        })
        self._old_installed_apps = settings.INSTALLED_APPS
        settings.INSTALLED_APPS = []
        self._warnings_state = get_warnings_state()
        warnings.simplefilter("ignore", PendingDeprecationWarning)
コード例 #6
0
ファイル: test_templatetags.py プロジェクト: slinkp/openblock
    def setUp(self):
        from django.test.utils import get_warnings_state
        import warnings
        self._warnings_state = get_warnings_state()
        warnings.filterwarnings('ignore', category=DeprecationWarning,
                                module='django.template.defaulttags')

        self.old_static_url = settings.STATIC_URL
        self.old_media_url = settings.MEDIA_URL
        settings.STATIC_URL = u"/static/"

        settings.MEDIA_URL = u"/media/"
コード例 #7
0
    def setUp(self):
        pkg_resources._provider_factories[MockLoader] = MockProvider

        self.empty_egg = create_egg("egg_empty", {})
        self.egg_1 = create_egg("egg_1", {
            os.path.normcase('templates/y.html') : StringIO.StringIO("y"),
            os.path.normcase('templates/x.txt') : StringIO.StringIO("x"),
        })
        self._old_installed_apps = settings.INSTALLED_APPS
        settings.INSTALLED_APPS = []
        self._warnings_state = get_warnings_state()
        warnings.filterwarnings("ignore", category=DeprecationWarning,
                                module='django.template.loaders.eggs')
コード例 #8
0
ファイル: loaders.py プロジェクト: ssaltzman/POET
    def setUp(self):
        pkg_resources._provider_factories[MockLoader] = MockProvider

        self.empty_egg = create_egg("egg_empty", {})
        self.egg_1 = create_egg(
            "egg_1",
            {
                os.path.normcase("templates/y.html"): StringIO.StringIO("y"),
                os.path.normcase("templates/x.txt"): StringIO.StringIO("x"),
            },
        )
        self._old_installed_apps = settings.INSTALLED_APPS
        settings.INSTALLED_APPS = []
        self._warnings_state = get_warnings_state()
        warnings.filterwarnings("ignore", category=DeprecationWarning, module="django.template.loaders.eggs")
コード例 #9
0
ファイル: tests.py プロジェクト: johnpaulett/django-old
    def test_raw_post_data_returns_body(self):
        """
        HttpRequest.raw_post_body should be the same as HttpRequest.body
        """
        payload = 'Hello There!'
        request = WSGIRequest({
            'REQUEST_METHOD': 'POST',
            'CONTENT_LENGTH': len(payload),
            'wsgi.input': StringIO(payload)
        })

        warnings_state = get_warnings_state()
        warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.http')
        try:
            self.assertEqual(request.body, request.raw_post_data)
        finally:
            restore_warnings_state(warnings_state)
コード例 #10
0
ファイル: tests.py プロジェクト: GdZ/scriptfile
    def test_raw_post_data_returns_body(self):
        """
        HttpRequest.raw_post_body should be the same as HttpRequest.body
        """
        payload = 'Hello There!'
        request = WSGIRequest({
            'REQUEST_METHOD': 'POST',
            'CONTENT_LENGTH': len(payload),
            'wsgi.input': StringIO(payload)
        })

        warnings_state = get_warnings_state()
        warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.http')
        try:
            self.assertEqual(request.body, request.raw_post_data)
        finally:
            restore_warnings_state(warnings_state)
コード例 #11
0
ファイル: tests.py プロジェクト: mick/django
    def test_filter_added(self):
        """
        Test that debug-false filter is added to mail_admins handler if it has
        no filters.

        """
        config = copy.deepcopy(OLD_LOGGING)

        warnings_state = get_warnings_state()
        warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.conf')
        try:
            compat_patch_logging_config(config)
        finally:
            restore_warnings_state(warnings_state)

        self.assertEqual(
            config["handlers"]["mail_admins"]["filters"],
            ['require_debug_false'])
コード例 #12
0
ファイル: tests.py プロジェクト: mick/django
    def test_POST_connection_error(self):
        """
        If wsgi.input.read() raises an exception while trying to read() the
        POST, the exception should be identifiable (not a generic IOError).
        """
        class ExplodingStringIO(StringIO):
            def read(self, len=0):
                raise IOError("kaboom!")

        payload = 'name=value'
        request = WSGIRequest({'REQUEST_METHOD': 'POST',
                               'CONTENT_LENGTH': len(payload),
                               'wsgi.input': ExplodingStringIO(payload)})

        warnings_state = get_warnings_state()
        warnings.filterwarnings('ignore', category=DeprecationWarning, module='django.http')
        try:
            with self.assertRaises(UnreadablePostError):
                request.raw_post_data
        finally:
            restore_warnings_state(warnings_state)
コード例 #13
0
    def test_invalid_keys(self):
        """
        All the builtin backends (except memcached, see below) should warn on
        keys that would be refused by memcached. This encourages portable
        caching code without making it too difficult to use production backends
        with more liberal key rules. Refs #6447.

        """
        # On Python 2.6+ we could use the catch_warnings context
        # manager to test this warning nicely. Since we can't do that
        # yet, the cleanest option is to temporarily ask for
        # CacheKeyWarning to be raised as an exception.
        _warnings_state = get_warnings_state()
        warnings.simplefilter("error", CacheKeyWarning)

        try:
            # memcached does not allow whitespace or control characters in keys
            self.assertRaises(CacheKeyWarning, self.cache.set, 'key with spaces', 'value')
            # memcached limits key length to 250
            self.assertRaises(CacheKeyWarning, self.cache.set, 'a' * 251, 'value')
        finally:
            restore_warnings_state(_warnings_state)
コード例 #14
0
ファイル: feed_tests.py プロジェクト: Aaron1011/oh-mainline
 def setUp(self):
     self._warnings_state = get_warnings_state()
     warnings.filterwarnings("ignore", category=DeprecationWarning,
                             module='django.contrib.syndication.views')
     warnings.filterwarnings("ignore", category=DeprecationWarning,
                             module='django.contrib.syndication.feeds')
コード例 #15
0
ファイル: utils.py プロジェクト: drawp/django-nonrel-drawp
 def save_warnings_state(self):
     self._warnings_state = get_warnings_state()
コード例 #16
0
ファイル: tests.py プロジェクト: Gautier/django_old
 def setUp(self):
     self.warning_state = get_warnings_state()
     warnings.filterwarnings('ignore',
                             category=PendingDeprecationWarning,
                             module='django.views.decorators.cache')
コード例 #17
0
ファイル: __init__.py プロジェクト: 101studio/django
 def setUp(self):
     self._warnings_state = get_warnings_state()
     warnings.filterwarnings('ignore', category=DeprecationWarning,
                             module='django.contrib.formtools.utils')
コード例 #18
0
ファイル: tests.py プロジェクト: mick/django
 def setUp(self):
     self.warning_state = get_warnings_state()
     warnings.filterwarnings('ignore', category=DeprecationWarning,
                             module='django.views.decorators.cache')
コード例 #19
0
ファイル: tests.py プロジェクト: girum11/hang
 def setUp(self):
     self._warnings_state = get_warnings_state()
     warnings.filterwarnings('ignore',
                             category=DeprecationWarning,
                             module='django.test.simple')
コード例 #20
0
ファイル: test_warnings.py プロジェクト: FactFiber/django-ff
 def setUp(self):
     self.warning_state = get_warnings_state()
     self.old_settings_module = settings.SETTINGS_MODULE
     settings.SETTINGS_MODULE = 'regressiontests'
     self.old_locale_paths = settings.LOCALE_PATHS
コード例 #21
0
 def save_warnings_state(self):
     """
     Saves the state of the warnings module
     """
     self._warnings_state = get_warnings_state()
コード例 #22
0
ファイル: utils.py プロジェクト: 101studio/django
 def save_warnings_state(self):
     self._warnings_state = get_warnings_state()
コード例 #23
0
ファイル: __init__.py プロジェクト: FactFiber/django-ff
 def setUp(self):
     self._warnings_state = get_warnings_state()
     warnings.filterwarnings('ignore',
                             category=DeprecationWarning,
                             module='django.contrib.formtools.utils')
コード例 #24
0
ファイル: testcases.py プロジェクト: 0xmilk/appscale
 def save_warnings_state(self):
     """
     Saves the state of the warnings module
     """
     self._warnings_state = get_warnings_state()
コード例 #25
0
ファイル: tests.py プロジェクト: 101studio/django
 def setUp(self):
     self._warnings_state = get_warnings_state()
     warnings.filterwarnings('ignore', category=DeprecationWarning,
                             module='django.test.simple')