Skip to content

Commit 0579b94

Browse files
committed
fix print failure
1 parent 16246c7 commit 0579b94

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

lymbo/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from lymbo.resource_manager import scope_global
1111
from lymbo.resource_manager import scope_module
1212

13-
__version__ = "0.2.1"
13+
__version__ = "0.2.2"
1414

1515
__all__ = [
1616
"args",

lymbo/item.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,22 @@ def __error_message(self, reason) -> List[str]:
203203

204204
message = []
205205

206-
first_line_test = 3 if self.asynchronous else 2
207-
208206
if reason:
209207
tb = traceback.extract_tb(reason.__traceback__)
210208

209+
first_line_test = 0
210+
211+
while first_line_test < len(tb):
212+
filename, _, funcname, _ = tb[first_line_test]
213+
214+
if filename.endswith(str(self.path)) and self.fnc == funcname:
215+
break
216+
217+
first_line_test += 1
218+
211219
if len(tb) > first_line_test:
212220
# We get the line in the test where the exception has been raised
213-
filename, lineno, funcname, text = tb[first_line_test]
221+
filename, lineno, funcname, _ = tb[first_line_test]
214222

215223
message.append(
216224
f"{type(reason).__name__} in {filename}, line {lineno}, in {funcname}:"
@@ -327,16 +335,16 @@ def failures(
327335
test_output = [line for line in test.output.getvalue().split("\n")]
328336
if test_output and not test_output[-1].strip():
329337
del test_output[-1]
330-
if test_output:
331-
output.append(" - - - - output:")
332-
for line in test_output:
333-
output.append(f"{padding}{line}")
334-
output.append(" - - - - reason:")
335338
if report_failure in (
336339
ReportFailure.SIMPLE,
337340
ReportFailure.NORMAL,
338341
ReportFailure.FULL,
339342
):
343+
if test_output:
344+
output.append(" - - - - output:")
345+
for line in test_output:
346+
output.append(f"{padding}{line}")
347+
output.append(" - - - - reason:")
340348
output.append(f"{padding}{test.reason}")
341349
if report_failure in (ReportFailure.NORMAL, ReportFailure.FULL):
342350
output.append(f"{padding}---------------------")

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "lymbo"
77
authors = [
88
{name = "cle-b", email = "cle@tictac.pm"},
99
]
10-
description="Test runner."
10+
description="A test runner designed for large test suites."
1111
readme="README.md"
1212
requires-python = ">=3.9"
1313
license = {text = "Apache-2.0"}

0 commit comments

Comments
 (0)