當前位置: 首頁>>代碼示例>>Python>>正文


Python deprecation.RemovedInDjango30Warning方法代碼示例

本文整理匯總了Python中django.utils.deprecation.RemovedInDjango30Warning方法的典型用法代碼示例。如果您正苦於以下問題:Python deprecation.RemovedInDjango30Warning方法的具體用法?Python deprecation.RemovedInDjango30Warning怎麽用?Python deprecation.RemovedInDjango30Warning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.utils.deprecation的用法示例。


在下文中一共展示了deprecation.RemovedInDjango30Warning方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_inline_admin_warning

# 需要導入模塊: from django.utils import deprecation [as 別名]
# 或者: from django.utils.deprecation import RemovedInDjango30Warning [as 別名]
def test_inline_admin_warning(self):
        class SongInlineAdmin(TabularInline):
            model = Song

            def has_add_permission(self, request):
                return super().has_add_permission(request)

        class BandAdmin(ModelAdmin):
            inlines = [SongInlineAdmin]

        msg = (
            "Update SongInlineAdmin.has_add_permission() to accept a "
            "positional `obj` argument."
        )
        with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
            self.assertIsValid(BandAdmin, Band) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:18,代碼來源:test_has_add_permission_obj_deprecation.py

示例2: test

# 需要導入模塊: from django.utils import deprecation [as 別名]
# 或者: from django.utils.deprecation import RemovedInDjango30Warning [as 別名]
def test(self):
        """
        admin_static.static points to the collectstatic version
        (as django.contrib.collectstatic is in INSTALLED_APPS).
        """
        msg = (
            '{% load admin_static %} is deprecated in favor of '
            '{% load static %}.'
        )
        old_url = staticfiles_storage.base_url
        staticfiles_storage.base_url = '/test/'
        try:
            with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
                url = static('path')
            self.assertEqual(url, '/test/path')
        finally:
            staticfiles_storage.base_url = old_url 
開發者ID:nesdis,項目名稱:djongo,代碼行數:19,代碼來源:test_static_deprecation.py

示例3: xreadlines

# 需要導入模塊: from django.utils import deprecation [as 別名]
# 或者: from django.utils.deprecation import RemovedInDjango30Warning [as 別名]
def xreadlines(self):
        warnings.warn(
            'HttpRequest.xreadlines() is deprecated in favor of iterating the '
            'request.', RemovedInDjango30Warning, stacklevel=2,
        )
        yield from self 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:8,代碼來源:request.py

示例4: test_field_name_kwarg_deprecation

# 需要導入模塊: from django.utils import deprecation [as 別名]
# 或者: from django.utils.deprecation import RemovedInDjango30Warning [as 別名]
def test_field_name_kwarg_deprecation(self):
        Person.objects.create(name='Deprecator', birthday=datetime(1950, 1, 1))
        msg = (
            'The field_name keyword argument to earliest() and latest() '
            'is deprecated in favor of passing positional arguments.'
        )
        with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
            Person.objects.latest(field_name='birthday') 
開發者ID:nesdis,項目名稱:djongo,代碼行數:10,代碼來源:tests.py

示例5: test_override_settings_warning

# 需要導入模塊: from django.utils import deprecation [as 別名]
# 或者: from django.utils.deprecation import RemovedInDjango30Warning [as 別名]
def test_override_settings_warning(self):
        with self.assertRaisesMessage(RemovedInDjango30Warning, self.msg):
            with self.settings(DEFAULT_CONTENT_TYPE='text/xml'):
                pass 
開發者ID:nesdis,項目名稱:djongo,代碼行數:6,代碼來源:test_default_content_type.py

示例6: test_settings_init_warning

# 需要導入模塊: from django.utils import deprecation [as 別名]
# 或者: from django.utils.deprecation import RemovedInDjango30Warning [as 別名]
def test_settings_init_warning(self):
        settings_module = ModuleType('fake_settings_module')
        settings_module.DEFAULT_CONTENT_TYPE = 'text/xml'
        settings_module.SECRET_KEY = 'abc'
        sys.modules['fake_settings_module'] = settings_module
        try:
            with self.assertRaisesMessage(RemovedInDjango30Warning, self.msg):
                Settings('fake_settings_module')
        finally:
            del sys.modules['fake_settings_module'] 
開發者ID:nesdis,項目名稱:djongo,代碼行數:12,代碼來源:test_default_content_type.py

示例7: test_templatetag_deprecated

# 需要導入模塊: from django.utils import deprecation [as 別名]
# 或者: from django.utils.deprecation import RemovedInDjango30Warning [as 別名]
def test_templatetag_deprecated(self):
        msg = '{% load staticfiles %} is deprecated in favor of {% load static %}.'
        template = "{% load staticfiles %}{% static 'main.js' %}"
        with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
            template = Template(template)
        rendered = template.render(Context())
        self.assertEqual(rendered, 'https://example.com/assets/main.js') 
開發者ID:nesdis,項目名稱:djongo,代碼行數:9,代碼來源:test_templatetag_deprecation.py

示例8: test_static_deprecated

# 需要導入模塊: from django.utils import deprecation [as 別名]
# 或者: from django.utils.deprecation import RemovedInDjango30Warning [as 別名]
def test_static_deprecated(self):
        msg = (
            'django.contrib.staticfiles.templatetags.static() is deprecated in '
            'favor of django.templatetags.static.static().'
        )
        with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
            url = static('main.js')
        self.assertEqual(url, 'https://example.com/assets/main.js') 
開發者ID:nesdis,項目名稱:djongo,代碼行數:10,代碼來源:test_templatetag_deprecation.py

示例9: test_deprecation

# 需要導入模塊: from django.utils import deprecation [as 別名]
# 或者: from django.utils.deprecation import RemovedInDjango30Warning [as 別名]
def test_deprecation(self):
        msg = (
            'Remove the context parameter from CashFieldDeprecated.from_db_value(). '
            'Support for it will be removed in Django 3.0.'
        )
        CashModelDeprecated.objects.create(cash='12.50')
        with self.assertWarnsMessage(RemovedInDjango30Warning, msg):
            instance = CashModelDeprecated.objects.get()
        self.assertIsInstance(instance.cash, Cash) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:11,代碼來源:test_deprecated.py

示例10: warnings_as_errors

# 需要導入模塊: from django.utils import deprecation [as 別名]
# 或者: from django.utils.deprecation import RemovedInDjango30Warning [as 別名]
def warnings_as_errors():
    """
    Convert warnings to errors. This should only affect unit tests, letting pylint and other plugins
    raise DeprecationWarnings without erroring.
    """
    try:
        warnings.resetwarnings()
        warnings.simplefilter('error')
        # For celery
        warnings.simplefilter('ignore', category=ImportWarning)
        warnings.filterwarnings(
            "ignore",
            message="'async' and 'await' will become reserved keywords in Python 3.7",
            category=DeprecationWarning,
        )
        warnings.filterwarnings(
            "ignore",
            message=(
                "Using or importing the ABCs from 'collections' instead of "
                "from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working"
            ),
            category=DeprecationWarning
        )
        warnings.filterwarnings(
            "ignore",
            message=(
                "Using or importing the ABCs from 'collections' instead of "
                "from 'collections.abc' is deprecated, and in 3.8 it will stop working"
            ),
            category=DeprecationWarning
        )
        # For compatibility modules in various libraries
        warnings.filterwarnings(
            "ignore",
            module=".*(compat|permission_tags).*",
        )
        # For pysftp
        warnings.filterwarnings(
            "ignore",
            category=UserWarning,
            message='Failed to load HostKeys',
        )
        # For Django 3.0 compatibility, which we don't care about yet
        warnings.filterwarnings("ignore", category=RemovedInDjango30Warning)

        yield
    finally:
        warnings.resetwarnings() 
開發者ID:mitodl,項目名稱:micromasters,代碼行數:50,代碼來源:conftest.py


注:本文中的django.utils.deprecation.RemovedInDjango30Warning方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。