Python Selenium定义自定义TimeoutException
我有一个pytest脚本,它有多个类,每个类都有一组测试。目前,每个类中的每个测试都定义了相同的TimeoutException。比如说,Python Selenium定义自定义TimeoutException,python,python-3.x,selenium,pytest,timeoutexception,Python,Python 3.x,Selenium,Pytest,Timeoutexception,我有一个pytest脚本,它有多个类,每个类都有一组测试。目前,每个类中的每个测试都定义了相同的TimeoutException。比如说, class Test1: def test_1: try: "do something" except TimeoutException: "handle exception" def test_2: tr
class Test1:
def test_1:
try:
"do something"
except TimeoutException:
"handle exception"
def test_2:
try:
"do something"
except TimeoutException:
"handle exception"
class Test2:
def test_3:
try:
"do something"
except TimeoutException:
"handle exception"
“handleexception”部分是每个模块都有相同代码的部分。我想知道是否有一种更像蟒蛇的方式来做到这一点。在我的TimeoutException处理程序的每个模块中粘贴相同的行似乎有些草率
任何帮助都是感激的,如果需要更多的信息,请让我知道
提前谢谢