MCPcopy Create free account
hub / github.com/numpy/numpy / _expect_error

Method _expect_error

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

Source from the content-addressed store, hash-verified

164
165 # Helper function mimicing pytest.raises for subprocess call
166 def _expect_error(
167 self,
168 msg,
169 err_type,
170 no_error_msg="Failed to generate error"
171 ):
172 try:
173 self._run()
174 except subprocess.CalledProcessError as e:
175 assertion_message = f"Expected: {msg}\nGot: {e.stderr}"
176 assert re.search(msg, e.stderr), assertion_message
177
178 assertion_message = (
179 f"Expected error of type: {err_type}; see full "
180 f"error:\n{e.stderr}"
181 )
182 assert re.search(err_type, e.stderr), assertion_message
183 else:
184 assert False, no_error_msg
185
186 def setup_method(self):
187 """Ensure that the environment is reset"""

Calls 1

_runMethod · 0.95

Tested by

no test coverage detected