MCPcopy Index your code
hub / github.com/numpy/numpy / _expect_error

Method _expect_error

numpy/_core/tests/test_cpu_features.py:176–194  ·  view source on GitHub ↗
(
        self,
        msg,
        err_type,
        no_error_msg="Failed to generate error"
    )

Source from the content-addressed store, hash-verified

174
175 # Helper function mimicking pytest.raises for subprocess call
176 def _expect_error(
177 self,
178 msg,
179 err_type,
180 no_error_msg="Failed to generate error"
181 ):
182 try:
183 self._run()
184 except subprocess.CalledProcessError as e:
185 assertion_message = f"Expected: {msg}\nGot: {e.stderr}"
186 assert re.search(msg, e.stderr), assertion_message
187
188 assertion_message = (
189 f"Expected error of type: {err_type}; see full "
190 f"error:\n{e.stderr}"
191 )
192 assert re.search(err_type, e.stderr), assertion_message
193 else:
194 assert False, no_error_msg
195
196 def setup_method(self):
197 """Ensure that the environment is reset"""

Calls 1

_runMethod · 0.95

Tested by

no test coverage detected