@@ -144,9 +144,9 @@ def test_render_debug_better_error_message_recursion_error():
144144 assert re .match (expected , io .fetch_output ()) is not None
145145
146146
147- def test_render_verbose_better_error_message ():
147+ def test_render_very_verbose_better_error_message ():
148148 io = BufferedIO ()
149- io .set_verbosity (Verbosity .VERBOSE )
149+ io .set_verbosity (Verbosity .VERY_VERBOSE )
150150
151151 try :
152152 fail ()
@@ -158,7 +158,7 @@ def test_render_verbose_better_error_message():
158158 expected = r"""^
159159 Stack trace:
160160
161- 1 {}:152 in test_render_verbose_better_error_message
161+ 1 {}:152 in test_render_very_verbose_better_error_message
162162 fail\(\)
163163
164164 Exception
@@ -192,7 +192,7 @@ def second():
192192
193193def test_render_debug_better_error_message_recursion_error_with_multiple_duplicated_frames ():
194194 io = BufferedIO ()
195- io .set_verbosity (Verbosity .VERBOSE )
195+ io .set_verbosity (Verbosity .VERY_VERBOSE )
196196
197197 with pytest .raises (RecursionError ) as e :
198198 first ()
@@ -212,7 +212,7 @@ def test_render_can_ignore_given_files():
212212 from tests .ui .helpers import outer
213213
214214 io = BufferedIO ()
215- io .set_verbosity (Verbosity .VERBOSE )
215+ io .set_verbosity (Verbosity .VERY_VERBOSE )
216216
217217 def call ():
218218 def run ():
@@ -477,3 +477,60 @@ def test():
477477 " ..." ,
478478 "" ,
479479 ]
480+
481+
482+ def test_simple_render ():
483+ io = BufferedIO ()
484+
485+ with pytest .raises (Exception ) as e :
486+ fail ()
487+
488+ trace = ExceptionTrace (e .value )
489+
490+ trace .render (io , simple = True )
491+
492+ expected = """
493+ Failed
494+ """
495+
496+ assert expected == io .fetch_output ()
497+
498+
499+ def test_simple_render_supports_solutions ():
500+ from crashtest .contracts .base_solution import BaseSolution
501+ from crashtest .contracts .provides_solution import ProvidesSolution
502+ from crashtest .solution_providers .solution_provider_repository import (
503+ SolutionProviderRepository ,
504+ )
505+
506+ class CustomError (ProvidesSolution , Exception ):
507+ @property
508+ def solution (self ):
509+ solution = BaseSolution ("Solution Title." , "Solution Description" )
510+ solution .documentation_links .append ("https://example.com" )
511+ solution .documentation_links .append ("https://example2.com" )
512+
513+ return solution
514+
515+ io = BufferedIO ()
516+
517+ def call ():
518+ raise CustomError ("Error with solution" )
519+
520+ with pytest .raises (CustomError ) as e :
521+ call ()
522+
523+ trace = ExceptionTrace (
524+ e .value , solution_provider_repository = SolutionProviderRepository ()
525+ )
526+
527+ trace .render (io , simple = True )
528+
529+ expected = """
530+ Error with solution
531+
532+ • Solution Title: Solution Description
533+ https://example.com,
534+ https://example2.com
535+ """
536+ assert expected == io .fetch_output ()
0 commit comments