From 1b4f93f14b87b0c5aae0865453729af156d54a29 Mon Sep 17 00:00:00 2001 From: Tamas Kocsis Date: Mon, 30 Nov 2020 14:37:45 +0100 Subject: [PATCH] Make Debug message test cases independent from line numbers, Windows support --- src/Test/TestDebug.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Test/TestDebug.py b/src/Test/TestDebug.py index f7708c78..e3eb20b3 100644 --- a/src/Test/TestDebug.py +++ b/src/Test/TestDebug.py @@ -1,6 +1,7 @@ from Debug import Debug import gevent import os +import re import pytest @@ -37,17 +38,15 @@ class TestDebug: q_items.append((file, int(line))) assert Debug.formatTraceback(q_items) == expected - def testFormatException(self): try: raise ValueError("Test exception") - except: - assert Debug.formatException() == "ValueError: Test exception in TestDebug.py line 43" + except Exception: + assert re.match(r"ValueError: Test exception in TestDebug.py line [0-9]+", Debug.formatException()) try: os.path.abspath(1) - except: - assert "in TestDebug.py line 47 > line " in Debug.formatException() - + except Exception: + assert re.search(r"in TestDebug.py line [0-9]+ > <(posixpath|ntpath)> line ", Debug.formatException()) def testFormatStack(self): - assert Debug.formatStack().startswith("TestDebug.py line 53 > <_pytest>/python.py line ") \ No newline at end of file + assert re.match(r"TestDebug.py line [0-9]+ > <_pytest>/python.py line [0-9]+", Debug.formatStack())