本文整理匯總了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)
示例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
示例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)