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
|
from Debug import Debug
|
||||||
import gevent
|
import gevent
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
@ -37,17 +38,15 @@ class TestDebug:
|
||||||
q_items.append((file, int(line)))
|
q_items.append((file, int(line)))
|
||||||
assert Debug.formatTraceback(q_items) == expected
|
assert Debug.formatTraceback(q_items) == expected
|
||||||
|
|
||||||
|
|
||||||
def testFormatException(self):
|
def testFormatException(self):
|
||||||
try:
|
try:
|
||||||
raise ValueError("Test exception")
|
raise ValueError("Test exception")
|
||||||
except:
|
except Exception:
|
||||||
assert Debug.formatException() == "ValueError: Test exception in TestDebug.py line 43"
|
assert re.match(r"ValueError: Test exception in TestDebug.py line [0-9]+", Debug.formatException())
|
||||||
try:
|
try:
|
||||||
os.path.abspath(1)
|
os.path.abspath(1)
|
||||||
except:
|
except Exception:
|
||||||
assert "in TestDebug.py line 47 > <posixpath> line " in Debug.formatException()
|
assert re.search(r"in TestDebug.py line [0-9]+ > <(posixpath|ntpath)> line ", Debug.formatException())
|
||||||
|
|
||||||
|
|
||||||
def testFormatStack(self):
|
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