Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Selenium定义自定义TimeoutException_Python_Python 3.x_Selenium_Pytest_Timeoutexception - Fatal编程技术网

Python Selenium定义自定义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

我有一个pytest脚本,它有多个类,每个类都有一组测试。目前,每个类中的每个测试都定义了相同的TimeoutException。比如说,

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处理程序的每个模块中粘贴相同的行似乎有些草率

任何帮助都是感激的,如果需要更多的信息,请让我知道

提前谢谢