Skip to content

Commit f3a2b6e

Browse files
committed
Update test
1 parent 1e02c9a commit f3a2b6e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

test/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import sys
66
import unittest
77
from importlib import reload
8+
from io import StringIO
89

910

1011
class CustomTestCase(unittest.TestCase):
@@ -32,10 +33,11 @@ def without_import(self, library, module):
3233
yield
3334
reload(module)
3435

36+
# recipe modified from https://stackoverflow.com/a/36491341
3537
@contextlib.contextmanager
36-
def replace_stdin(self, target):
38+
def replace_stdin(self, target: str):
3739
orig = sys.stdin
38-
sys.stdin = target
40+
sys.stdin = StringIO(target)
3941
yield
4042
sys.stdin = orig
4143

test/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ def test_bad_version(self):
866866

867867
def test_interactive_extra_args(self):
868868
with LogCapture() as log:
869-
with self.replace_stdin(io.StringIO("9.99.9\n")):
869+
with self.replace_stdin("9.99.9\n"):
870870
res = install_cmdstan(version="2.29.2", interactive=True)
871871
log.check_present(
872872
(

0 commit comments

Comments
 (0)