Make Debug message test cases independent from line numbers, Windows support
This commit is contained in:
parent
40db30a260
commit
1b4f93f14b
1 changed files with 6 additions and 7 deletions
|
@ -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 > <posixpath> 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 ")
|
||||
assert re.match(r"TestDebug.py line [0-9]+ > <_pytest>/python.py line [0-9]+", Debug.formatStack())
|
||||
|
|
Loading…
Reference in a new issue