Add tests for debug deprecation
update existing tests
Markus Gerstel
2 years ago
41 | 41 | task = ["___"] |
42 | 42 | |
43 | 43 | 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) | |
45 | 45 | |
46 | 46 | assert mock_subprocess.Popen.called |
47 | 47 | assert mock_process.terminate.called |
83 | 83 | actual = procrunner.run( |
84 | 84 | command, |
85 | 85 | timeout=0.5, |
86 | debug=False, | |
87 | 86 | callback_stdout=mock.sentinel.callback_stdout, |
88 | 87 | callback_stderr=mock.sentinel.callback_stderr, |
89 | 88 | working_directory=mock.sentinel.cwd, |
98 | 97 | mock.call( |
99 | 98 | stream_stdout, |
100 | 99 | output=mock.ANY, |
101 | debug=mock.ANY, | |
100 | debug=None, | |
102 | 101 | notify=mock.ANY, |
103 | 102 | callback=mock.sentinel.callback_stdout, |
104 | 103 | ), |
105 | 104 | mock.call( |
106 | 105 | stream_stderr, |
107 | 106 | output=mock.ANY, |
108 | debug=mock.ANY, | |
107 | debug=None, | |
109 | 108 | notify=mock.ANY, |
110 | 109 | callback=mock.sentinel.callback_stderr, |
111 | 110 | ), |
127 | 126 | def test_default_process_environment_is_parent_environment(mock_subprocess): |
128 | 127 | mock_subprocess.Popen.side_effect = NotImplementedError() # cut calls short |
129 | 128 | 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) | |
133 | 130 | 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) | |
134 | 142 | |
135 | 143 | |
136 | 144 | @mock.patch("procrunner.subprocess") |
142 | 150 | procrunner.run( |
143 | 151 | [mock.Mock()], |
144 | 152 | timeout=-1, |
145 | debug=False, | |
146 | 153 | environment=copy.copy(mock_env), |
147 | 154 | raise_timeout_exception=True, |
148 | 155 | ) |
159 | 166 | procrunner.run( |
160 | 167 | [mock.Mock()], |
161 | 168 | timeout=-1, |
162 | debug=False, | |
163 | 169 | environment=copy.copy(mock_env1), |
164 | 170 | environment_override=copy.copy(mock_env2), |
165 | 171 | raise_timeout_exception=True, |
177 | 183 | procrunner.run( |
178 | 184 | [mock.Mock()], |
179 | 185 | timeout=-1, |
180 | debug=False, | |
181 | 186 | environment_override=copy.copy(mock_env2), |
182 | 187 | raise_timeout_exception=True, |
183 | 188 | ) |
206 | 211 | procrunner.run( |
207 | 212 | [mock.Mock()], |
208 | 213 | timeout=-1, |
209 | debug=False, | |
210 | 214 | environment_override={ |
211 | 215 | random_environment_variable: "X" + random_environment_value |
212 | 216 | }, |