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


Python exc.SADeprecationWarning方法代碼示例

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


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

示例1: uses_deprecated

# 需要導入模塊: from sqlalchemy import exc [as 別名]
# 或者: from sqlalchemy.exc import SADeprecationWarning [as 別名]
def uses_deprecated(*messages):
    """Mark a test as immune from fatal deprecation warnings.

    With no arguments, squelches all SADeprecationWarning failures.
    Or pass one or more strings; these will be matched to the root
    of the warning description by warnings.filterwarnings().

    As a special case, you may pass a function name prefixed with //
    and it will be re-written as needed to match the standard warning
    verbiage emitted by the sqlalchemy.util.deprecated decorator.

    Note that uses_deprecated does **not** assert that the warnings
    were in fact seen.

    """

    @decorator
    def decorate(fn, *args, **kw):
        with expect_deprecated(*messages, assert_=False):
            return fn(*args, **kw)
    return decorate 
開發者ID:jpush,項目名稱:jbox,代碼行數:23,代碼來源:assertions.py

示例2: uses_deprecated

# 需要導入模塊: from sqlalchemy import exc [as 別名]
# 或者: from sqlalchemy.exc import SADeprecationWarning [as 別名]
def uses_deprecated(*messages):
    """Mark a test as immune from fatal deprecation warnings.

    With no arguments, squelches all SADeprecationWarning failures.
    Or pass one or more strings; these will be matched to the root
    of the warning description by warnings.filterwarnings().

    As a special case, you may pass a function name prefixed with //
    and it will be re-written as needed to match the standard warning
    verbiage emitted by the sqlalchemy.util.deprecated decorator.
    """

    @decorator
    def decorate(fn, *args, **kw):
        with expect_deprecated(*messages):
            return fn(*args, **kw)
    return decorate 
開發者ID:gltn,項目名稱:stdm,代碼行數:19,代碼來源:assertions.py

示例3: expect_deprecated

# 需要導入模塊: from sqlalchemy import exc [as 別名]
# 或者: from sqlalchemy.exc import SADeprecationWarning [as 別名]
def expect_deprecated(*messages):
    # todo: should probably be strict about this, too
    filters = [dict(action='ignore',
                    category=sa_exc.SAPendingDeprecationWarning)]
    if not messages:
        filters.append(dict(action='ignore',
                            category=sa_exc.SADeprecationWarning))
    else:
        filters.extend(
            [dict(action='ignore',
                  message=message,
                  category=sa_exc.SADeprecationWarning)
             for message in
             [(m.startswith('//') and
               ('Call to deprecated function ' + m[2:]) or m)
              for m in messages]])

    for f in filters:
        warnings.filterwarnings(**f)
    try:
        yield
    finally:
        resetwarnings() 
開發者ID:gltn,項目名稱:stdm,代碼行數:25,代碼來源:assertions.py

示例4: expect_deprecated

# 需要導入模塊: from sqlalchemy import exc [as 別名]
# 或者: from sqlalchemy.exc import SADeprecationWarning [as 別名]
def expect_deprecated(*messages):
    # todo: should probably be strict about this, too
    filters = [dict(action='ignore',
                    category=sa_exc.SAPendingDeprecationWarning)]
    if not messages:
        filters.append(dict(action='ignore',
                            category=sa_exc.SADeprecationWarning))
    else:
        filters.extend(
            [dict(action='ignore',
                  message=message,
                  category=sa_exc.SADeprecationWarning)
             for message in
             [(m.startswith('//') and
                ('Call to deprecated function ' + m[2:]) or m)
               for m in messages]])

    for f in filters:
        warnings.filterwarnings(**f)
    try:
        yield
    finally:
        resetwarnings() 
開發者ID:binhex,項目名稱:moviegrabber,代碼行數:25,代碼來源:assertions.py

示例5: test_deprecated_get_primary_keys

# 需要導入模塊: from sqlalchemy import exc [as 別名]
# 或者: from sqlalchemy.exc import SADeprecationWarning [as 別名]
def test_deprecated_get_primary_keys(self):
        meta = self.metadata
        users = self.tables.users
        insp = Inspector(meta.bind)
        assert_raises_message(
            sa_exc.SADeprecationWarning,
            "Call to deprecated method get_primary_keys."
            "  Use get_pk_constraint instead.",
            insp.get_primary_keys, users.name
        ) 
開發者ID:jpush,項目名稱:jbox,代碼行數:12,代碼來源:test_reflection.py

示例6: expect_deprecated

# 需要導入模塊: from sqlalchemy import exc [as 別名]
# 或者: from sqlalchemy.exc import SADeprecationWarning [as 別名]
def expect_deprecated(*messages, **kw):
    return _expect_warnings(sa_exc.SADeprecationWarning, messages, **kw) 
開發者ID:jpush,項目名稱:jbox,代碼行數:4,代碼來源:assertions.py

示例7: setup_filters

# 需要導入模塊: from sqlalchemy import exc [as 別名]
# 或者: from sqlalchemy.exc import SADeprecationWarning [as 別名]
def setup_filters():
    """Set global warning behavior for the test suite."""

    warnings.filterwarnings('ignore',
                            category=sa_exc.SAPendingDeprecationWarning)
    warnings.filterwarnings('error', category=sa_exc.SADeprecationWarning)
    warnings.filterwarnings('error', category=sa_exc.SAWarning) 
開發者ID:jpush,項目名稱:jbox,代碼行數:9,代碼來源:warnings.py

示例8: test_empty_clauses

# 需要導入模塊: from sqlalchemy import exc [as 別名]
# 或者: from sqlalchemy.exc import SADeprecationWarning [as 別名]
def test_empty_clauses(self, op, str_op, str_continue):
        # these warning classes will change to ArgumentError when the
        # deprecated behavior is disabled

        assert_raises_message(
            exc.SADeprecationWarning,
            r"Invoking %(str_op)s\(\) without arguments is deprecated, and "
            r"will be disallowed in a future release.   For an empty "
            r"%(str_op)s\(\) construct, use "
            r"%(str_op)s\(%(str_continue)s, \*args\)\."
            % {"str_op": str_op, "str_continue": str_continue},
            op,
        ) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:15,代碼來源:test_operators.py


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