用于处理和引发异常的python实用程序
ctodd-python-lib-exceptions的Python项目详细描述
克里斯托弗·托德的项目字符串名称
项目名称项目负责…
图书馆…
目录
依赖关系
python包
- 不适用
库
create_exceptions.py
异常帮助程序。此文件显示了python中的异常类型和用于生成特定异常的函数调用。这对于单元测试、调试和其他可能需要有意中断部分代码的任务非常有用。
功能:
def create_and_throw_exception(exception_name=None):
"""
Purpose:
Create and Throw an exception from the exception
types in the file. if exception_name is passed in,
throw that specific exception if it has been
coded in the library
Args:
exception_name (String ExceptionType): Type of exception
to throw
Returns:
N/A: should never return, should always raise
"""
def create_zero_division_exception():
"""
Purpose:
Throw ZeroDivisionError Exception
Args:
N/A
Returns:
N/A
"""
def create_overflow_exception():
"""
Purpose:
Throw OverflowError Exception
Args:
N/A
Returns:
N/A
"""
def create_type_exception():
"""
Purpose:
Throw TypeError Exception
Args:
N/A
Returns:
N/A
"""
def create_assertion_exception():
"""
Purpose:
Throw AssertionError Exception
Args:
N/A
Returns:
N/A
"""
def create_attribute_exception():
"""
Purpose:
Throw AttributeError Exception
Args:
N/A
Returns:
N/A
"""
def create_name_exception():
"""
Purpose:
Throw NameError Exception
Args:
N/A
Returns:
N/A
"""
def create_index_exception():
"""
Purpose:
Throw IndexError Exception
Args:
N/A
Returns:
N/A
"""
def create_key_exception():
"""
Purpose:
Throw KeyError Exception
Args:
N/A
Returns:
N/A
"""
def create_unbound_local_exception():
"""
Purpose:
Throw UnboundLocalError Exception
Args:
N/A
Returns:
N/A
"""
unsupported_exception.py
不支持异常类。当前不执行任何操作,但允许在create_exceptions中指定失败的调用
课程:
class UnsupportedException(Exception):
"""
Purpose:
An Unsupported Exception is raised when the lib is asked to try
and raise an exception that has yet to be programmed. this way,
som exception is raised, but it can be handled in a way that
knows the specified exception isn't raised
"""
脚本示例
用于测试和与库交互的示例可执行python脚本/模块。这些示例显示了库的用例,可以用作与库一起开发的模板,也可以用作一次性开发工作。
不适用
注释
- 依赖于f-string符号,它仅限于python3.6。通过重构删除这些内容,可以使用python3.0.x到3.5.x进行开发
待办事项
- UnitTest框架已就位,但缺少测试