Codebase list python-procrunner / d7b9ba6
Add tests for debug deprecation update existing tests Markus Gerstel 3 years ago
1 changed file(s) with 15 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
4141 task = ["___"]
4242
4343 with pytest.raises(RuntimeError):
44 procrunner.run(task, timeout=-1, debug=False, raise_timeout_exception=True)
44 procrunner.run(task, timeout=-1, raise_timeout_exception=True)
4545
4646 assert mock_subprocess.Popen.called
4747 assert mock_process.terminate.called
8383 actual = procrunner.run(
8484 command,
8585 timeout=0.5,
86 debug=False,
8786 callback_stdout=mock.sentinel.callback_stdout,
8887 callback_stderr=mock.sentinel.callback_stderr,
8988 working_directory=mock.sentinel.cwd,
9897 mock.call(
9998 stream_stdout,
10099 output=mock.ANY,
101 debug=mock.ANY,
100 debug=None,
102101 notify=mock.ANY,
103102 callback=mock.sentinel.callback_stdout,
104103 ),
105104 mock.call(
106105 stream_stderr,
107106 output=mock.ANY,
108 debug=mock.ANY,
107 debug=None,
109108 notify=mock.ANY,
110109 callback=mock.sentinel.callback_stderr,
111110 ),
127126 def test_default_process_environment_is_parent_environment(mock_subprocess):
128127 mock_subprocess.Popen.side_effect = NotImplementedError() # cut calls short
129128 with pytest.raises(NotImplementedError):
130 procrunner.run(
131 [mock.Mock()], timeout=-1, debug=False, raise_timeout_exception=True
132 )
129 procrunner.run([mock.Mock()], timeout=-1, raise_timeout_exception=True)
133130 assert mock_subprocess.Popen.call_args[1]["env"] == os.environ
131
132
133 @mock.patch("procrunner.subprocess")
134 def test_using_debug_parameter_raises_warning(mock_subprocess):
135 mock_subprocess.Popen.side_effect = NotImplementedError() # cut calls short
136 with pytest.warns(DeprecationWarning, match="debug"):
137 with pytest.raises(NotImplementedError):
138 procrunner.run([mock.Mock()], debug=True)
139 with pytest.warns(DeprecationWarning, match="debug"):
140 with pytest.raises(NotImplementedError):
141 procrunner.run([mock.Mock()], debug=False)
134142
135143
136144 @mock.patch("procrunner.subprocess")
142150 procrunner.run(
143151 [mock.Mock()],
144152 timeout=-1,
145 debug=False,
146153 environment=copy.copy(mock_env),
147154 raise_timeout_exception=True,
148155 )
159166 procrunner.run(
160167 [mock.Mock()],
161168 timeout=-1,
162 debug=False,
163169 environment=copy.copy(mock_env1),
164170 environment_override=copy.copy(mock_env2),
165171 raise_timeout_exception=True,
177183 procrunner.run(
178184 [mock.Mock()],
179185 timeout=-1,
180 debug=False,
181186 environment_override=copy.copy(mock_env2),
182187 raise_timeout_exception=True,
183188 )
206211 procrunner.run(
207212 [mock.Mock()],
208213 timeout=-1,
209 debug=False,
210214 environment_override={
211215 random_environment_variable: "X" + random_environment_value
212216 },