@@ -36,11 +36,15 @@ def setup_network(self):
3636 # Launches a child test process that runs this same file, but instantiates
3737 # a child test. Verifies that it raises only the expected exception, once.
3838 def _verify_startup_failure (self , test , internal_args , expected_exception ):
39+ name = test .__name__
40+ def format_child_output (output ):
41+ return f"\n <{ name } OUTPUT BEGIN>\n { output .strip ()} \n <{ name } OUTPUT END>\n "
42+
3943 # Inherit sys.argv from parent, only overriding tmpdir to a subdirectory
4044 # so children don't fail due to colliding with the parent dir.
4145 assert self .options .tmpdir , "Framework should always set tmpdir."
4246 subdir = md5 (expected_exception .encode ('utf-8' )).hexdigest ()[:8 ]
43- args = [sys .executable ] + sys .argv + [f"--tmpdir={ self .options .tmpdir } /{ subdir } " , f"--internal_test={ test . __name__ } " ] + internal_args
47+ args = [sys .executable ] + sys .argv + [f"--tmpdir={ self .options .tmpdir } /{ subdir } " , f"--internal_test={ name } " ] + internal_args
4448
4549 try :
4650 # The subprocess encoding argument gives different results for e.output
@@ -50,8 +54,8 @@ def _verify_startup_failure(self, test, internal_args, expected_exception):
5054 except subprocess .TimeoutExpired as e :
5155 print ("Unexpected child process timeout!\n "
5256 "WARNING: Timeouts like this halt execution of TestNode logic, "
53- "meaning dangling bitcoind processes are to be expected.\n "
54- f"<CHILD OUTPUT BEGIN> \n { e .output .decode ('utf-8' )} \n <CHILD OUTPUT END>" ,
57+ "meaning dangling bitcoind processes are to be expected.\n " +
58+ format_child_output ( e .output .decode ('utf-8' )) ,
5559 file = sys .stderr )
5660 raise
5761
@@ -63,13 +67,17 @@ def _verify_startup_failure(self, test, internal_args, expected_exception):
6367 if (n := output .count ("Test failed. Test logging available at" )) != 1 :
6468 errors .append (f"Found { n } /1 test failure output messages." )
6569
66- assert not errors , f"Child test didn't contain (only) expected errors:\n { linesep .join (errors )} \n <CHILD OUTPUT BEGIN>\n { output } \n <CHILD OUTPUT END>\n "
70+ assert not errors , (f"Child test did NOT contain (only) expected errors:\n { linesep .join (errors )} \n " +
71+ format_child_output (output ))
72+
73+ self .log .debug ("Child test did contain (only) expected errors:\n " +
74+ format_child_output (output ))
6775
6876 def run_test (self ):
6977 self .log .info ("Verifying _verify_startup_failure() functionality (self-check)." )
7078 assert_raises_message (
7179 AssertionError ,
72- ( "Child test didn't contain (only) expected errors:\n "
80+ ( "Child test did NOT contain (only) expected errors:\n "
7381 f"Found 0/1 tracebacks - expecting exactly one with no knock-on exceptions.{ linesep } "
7482 f"Found 0/1 occurrences of the specific exception: NonExistentError{ linesep } "
7583 "Found 0/1 test failure output messages." ),
0 commit comments