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


Python util.raise_from_cause方法代碼示例

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


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

示例1: test_raise_from_cause_legacy

# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import raise_from_cause [as 別名]
def test_raise_from_cause_legacy(self):
        class MyException(Exception):
            pass

        class MyOtherException(Exception):
            pass

        me = MyException("exc on")

        def go():
            try:
                raise me
            except Exception:
                util.raise_from_cause(MyOtherException("exc two"))

        try:
            go()
            assert False
        except MyOtherException as moe:
            if testing.requires.python3.enabled:
                is_(moe.__cause__, me) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:23,代碼來源:test_utils.py

示例2: visit_create_table

# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import raise_from_cause [as 別名]
def visit_create_table(self, create):
        table = create.element
        preparer = self.preparer

        text = "\nCREATE EXTERNAL "
        text += "TABLE " + preparer.format_table(table) + " "
        text += "("

        separator = "\n"
        for create_column in create.columns:
            column = create_column.element
            try:
                processed = self.process(create_column)
                if processed is not None:
                    text += separator
                    separator = ", \n"
                    text += "\t" + processed
            except exc.CompileError as ce:
                util.raise_from_cause(
                    exc.CompileError(
                        util.u("(in table '{0}', column '{1}'): {2}").format(
                            table.description, column.name, ce.args[0]
                        )
                    )
                )

        const = self.create_table_constraints(
            table,
            _include_foreign_key_constraints=create.include_foreign_key_constraints,
        )
        if const:
            text += separator + "\t" + const

        text += "\n)\n%s\n\n" % self.post_create_table(table)
        return text 
開發者ID:laughingman7743,項目名稱:PyAthena,代碼行數:37,代碼來源:sqlalchemy_athena.py

示例3: test_raise_from_cause_same_cause

# 需要導入模塊: from sqlalchemy import util [as 別名]
# 或者: from sqlalchemy.util import raise_from_cause [as 別名]
def test_raise_from_cause_same_cause(self):
        class MyException(Exception):
            pass

        def go():
            try:
                raise MyException("exc one")
            except Exception as err:
                util.raise_from_cause(err)

        try:
            go()
            assert False
        except MyException as err:
            is_(err.__cause__, None) 
開發者ID:sqlalchemy,項目名稱:sqlalchemy,代碼行數:17,代碼來源:test_utils.py


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