|
10 | 10 |
|
11 | 11 | from cmd2 import cmd2
|
12 | 12 | import cmd2_submenu
|
13 |
| -from conftest import run_cmd, StdOut, normalize |
14 |
| - |
| 13 | +from conftest import run_cmd, normalize |
| 14 | +from cmd2.utils import StdSim |
15 | 15 |
|
16 | 16 | class SecondLevelB(cmd2.Cmd):
|
17 | 17 | """To be used as a second level command class. """
|
@@ -88,32 +88,32 @@ def complete_say(self, text, line, begidx, endidx):
|
88 | 88 | @pytest.fixture
|
89 | 89 | def submenu_app():
|
90 | 90 | app = SubmenuApp()
|
91 |
| - app.stdout = StdOut() |
92 |
| - second_level_cmd.stdout = StdOut() |
93 |
| - second_level_b_cmd.stdout = StdOut() |
| 91 | + app.stdout = StdSim(app.stdout) |
| 92 | + second_level_cmd.stdout = StdSim(app.stdout) |
| 93 | + second_level_b_cmd.stdout = StdSim(app.stdout) |
94 | 94 | return app
|
95 | 95 |
|
96 | 96 |
|
97 | 97 | @pytest.fixture
|
98 | 98 | def secondlevel_app():
|
99 | 99 | app = SecondLevel()
|
100 |
| - app.stdout = StdOut() |
| 100 | + app.stdout = StdSim(app.stdout) |
101 | 101 | return app
|
102 | 102 |
|
103 | 103 |
|
104 | 104 | @pytest.fixture
|
105 | 105 | def secondlevel_app_b():
|
106 | 106 | app = SecondLevelB()
|
107 |
| - app.stdout = StdOut() |
| 107 | + app.stdout = StdSim(app.stdout) |
108 | 108 | return app
|
109 | 109 |
|
110 | 110 | def run_submenu_cmd(app, second_level_app, cmd):
|
111 |
| - """ Clear StdOut buffers, run the command, extract the buffer contents.""" |
| 111 | + """ Clear StdSim buffers, run the command, extract the buffer contents.""" |
112 | 112 | app.stdout.clear()
|
113 | 113 | second_level_app.stdout.clear()
|
114 | 114 | app.onecmd_plus_hooks(cmd)
|
115 |
| - out1 = app.stdout.buffer |
116 |
| - out2 = second_level_app.stdout.buffer |
| 115 | + out1 = app.stdout.getvalue() |
| 116 | + out2 = second_level_app.stdout.getvalue() |
117 | 117 | app.stdout.clear()
|
118 | 118 | second_level_app.stdout.clear()
|
119 | 119 | return normalize(out1), normalize(out2)
|
|
0 commit comments