Skip to content

Commit d7b9ba6

Browse files
committed
Add tests for debug deprecation
update existing tests
1 parent b2d1ac3 commit d7b9ba6

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

tests/test_procrunner.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_run_command_aborts_after_timeout(
4242
task = ["___"]
4343

4444
with pytest.raises(RuntimeError):
45-
procrunner.run(task, timeout=-1, debug=False, raise_timeout_exception=True)
45+
procrunner.run(task, timeout=-1, raise_timeout_exception=True)
4646

4747
assert mock_subprocess.Popen.called
4848
assert mock_process.terminate.called
@@ -84,7 +84,6 @@ def streamreader_processing(*args, **kwargs):
8484
actual = procrunner.run(
8585
command,
8686
timeout=0.5,
87-
debug=False,
8887
callback_stdout=mock.sentinel.callback_stdout,
8988
callback_stderr=mock.sentinel.callback_stderr,
9089
working_directory=mock.sentinel.cwd,
@@ -99,14 +98,14 @@ def streamreader_processing(*args, **kwargs):
9998
mock.call(
10099
stream_stdout,
101100
output=mock.ANY,
102-
debug=mock.ANY,
101+
debug=None,
103102
notify=mock.ANY,
104103
callback=mock.sentinel.callback_stdout,
105104
),
106105
mock.call(
107106
stream_stderr,
108107
output=mock.ANY,
109-
debug=mock.ANY,
108+
debug=None,
110109
notify=mock.ANY,
111110
callback=mock.sentinel.callback_stderr,
112111
),
@@ -128,12 +127,21 @@ def streamreader_processing(*args, **kwargs):
128127
def test_default_process_environment_is_parent_environment(mock_subprocess):
129128
mock_subprocess.Popen.side_effect = NotImplementedError() # cut calls short
130129
with pytest.raises(NotImplementedError):
131-
procrunner.run(
132-
[mock.Mock()], timeout=-1, debug=False, raise_timeout_exception=True
133-
)
130+
procrunner.run([mock.Mock()], timeout=-1, raise_timeout_exception=True)
134131
assert mock_subprocess.Popen.call_args[1]["env"] == os.environ
135132

136133

134+
@mock.patch("procrunner.subprocess")
135+
def test_using_debug_parameter_raises_warning(mock_subprocess):
136+
mock_subprocess.Popen.side_effect = NotImplementedError() # cut calls short
137+
with pytest.warns(DeprecationWarning, match="debug"):
138+
with pytest.raises(NotImplementedError):
139+
procrunner.run([mock.Mock()], debug=True)
140+
with pytest.warns(DeprecationWarning, match="debug"):
141+
with pytest.raises(NotImplementedError):
142+
procrunner.run([mock.Mock()], debug=False)
143+
144+
137145
@mock.patch("procrunner.subprocess")
138146
def test_pass_custom_environment_to_process(mock_subprocess):
139147
mock_subprocess.Popen.side_effect = NotImplementedError() # cut calls short
@@ -143,7 +151,6 @@ def test_pass_custom_environment_to_process(mock_subprocess):
143151
procrunner.run(
144152
[mock.Mock()],
145153
timeout=-1,
146-
debug=False,
147154
environment=copy.copy(mock_env),
148155
raise_timeout_exception=True,
149156
)
@@ -160,7 +167,6 @@ def test_pass_custom_environment_to_process_and_add_another_value(mock_subproces
160167
procrunner.run(
161168
[mock.Mock()],
162169
timeout=-1,
163-
debug=False,
164170
environment=copy.copy(mock_env1),
165171
environment_override=copy.copy(mock_env2),
166172
raise_timeout_exception=True,
@@ -178,7 +184,6 @@ def test_use_default_process_environment_and_add_another_value(mock_subprocess):
178184
procrunner.run(
179185
[mock.Mock()],
180186
timeout=-1,
181-
debug=False,
182187
environment_override=copy.copy(mock_env2),
183188
raise_timeout_exception=True,
184189
)
@@ -207,7 +212,6 @@ def test_use_default_process_environment_and_override_a_value(mock_subprocess):
207212
procrunner.run(
208213
[mock.Mock()],
209214
timeout=-1,
210-
debug=False,
211215
environment_override={
212216
random_environment_variable: "X" + random_environment_value
213217
},

0 commit comments

Comments
 (0)