Merge bitcoin/bitcoin#33951: test: check for output to stdout in TestShell test
52230a7f69test: check for output to stdout in `TestShell` test (Sebastian Falbesoner) Pull request description: This is a small follow-up PR to the recently added `TestShell` test (#33546), verifying the stdout message "TestShell is already running!" when trying to instantiate a second instance. ACKs for top commit: maflcko: lgtm ACK52230a7f69rkrux: crACK52230a7f69Tree-SHA512: 096d70e1bd0f09c1b389e58fa4b880442406c56f0c8ef8b8fbd0627081bc390b1ce5d6032bcca19b03206b7a444d9c523f9b62078b5ca5b7f1ae3c57bb4129c9
This commit is contained in:
1 file changed
+7
-2
@@ -4,7 +4,9 @@
|
|||||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
"""Tests for the `TestShell` submodule."""
|
"""Tests for the `TestShell` submodule."""
|
||||||
|
|
||||||
|
from contextlib import redirect_stdout
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
from io import StringIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# Note that we need to import from functional test framework modules
|
# Note that we need to import from functional test framework modules
|
||||||
@@ -24,8 +26,11 @@ def run_testshell_doc_example(functional_tests_dir):
|
|||||||
test = TestShell().setup(num_nodes=2, setup_clean_chain=True)
|
test = TestShell().setup(num_nodes=2, setup_clean_chain=True)
|
||||||
try:
|
try:
|
||||||
assert test is not None
|
assert test is not None
|
||||||
test2 = TestShell().setup()
|
stdout_buf = StringIO()
|
||||||
assert test2 is None # TODO: check for "TestShell is already running!" output to stdout
|
with redirect_stdout(stdout_buf):
|
||||||
|
test2 = TestShell().setup()
|
||||||
|
assert test2 is None
|
||||||
|
assert_equal(stdout_buf.getvalue().rstrip(), "TestShell is already running!")
|
||||||
assert_equal(test.nodes[0].getblockchaininfo()["blocks"], 0)
|
assert_equal(test.nodes[0].getblockchaininfo()["blocks"], 0)
|
||||||
if test.is_wallet_compiled():
|
if test.is_wallet_compiled():
|
||||||
res = test.nodes[0].createwallet('default')
|
res = test.nodes[0].createwallet('default')
|
||||||
|
|||||||
Reference in new issue
Block a user