You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert_almost_equal (or floating point comparison [MRG] nosetests to pytests #310)
Instead of using the nose2pytest's default transformation which changes assert_almost_equal(a, b, delta[,msg]) into assert abs(a-b) <= delta[, msg], we chose to use the approx helper function that translates to assert a == approx(b, [abs=delta])[, msg]. In this manner:
assert_raise [MRG] Migrate raising errors from nose to pytest #321
Based on the documentation here, assert_raises(ValueError, func, *args, **kwargs ) can become: pytest.raises(ValueError, func, *args, **kwargs ), pytest.raises(ValueError, "func(*args, **kwargs)" ) or with raises(ValueError): func(*args, **kwargs). The first option can be done using find-replace but we latter is preferred for readability. (it has been carried out manually) here is an example:
- assert_raises(TypeError, Pipeline)+ with raises(TypeError):+ Pipeline()
assert_array_equal, assert_array_almost_equal, etc belong to numpy not nosetests. So we don't need to translate them. I would like to translate them but they are not supported by numpy.
I'll check whenever is not an array and change it by pytest.
Migrate the value validation
assert_equal (nose2pytest) [MRG] nosetests to pytests #310
assert_almost_equal (or floating point comparison [MRG] nosetests to pytests #310)
Instead of using the nose2pytest's default transformation which changes
assert_almost_equal(a, b, delta[,msg])
intoassert abs(a-b) <= delta[, msg]
, we chose to use the approx helper function that translates toassert a == approx(b, [abs=delta])[, msg]
. In this manner:assert_array_equal
assert_array_almost_equal
assert_allclose
Migrate raising checks
assert_raise [MRG] Migrate raising errors from nose to pytest #321
Based on the documentation here,
assert_raises(ValueError, func, *args, **kwargs )
can become:pytest.raises(ValueError, func, *args, **kwargs )
,pytest.raises(ValueError, "func(*args, **kwargs)" )
orwith raises(ValueError): func(*args, **kwargs)
. The first option can be done using find-replace but we latter is preferred for readability. (it has been carried out manually)here is an example:
assert_raises_regex [MRG] Migrate raising errors from nose to pytest #321
See
match(regexp)
hereIn example:
assert_raise_message ([MRG] Migrate raising errors from nose to pytest #321: f8ad59e)
Use assert + regex match.
assert_warns
Deprecation warnings are treated different (see this)
assert_warns_message
assert_no_warnings
my_assert (this is a custom assert with in a loop here)
yield
Set-up and tare-down become fixtures
Other things to migrate
The text was updated successfully, but these errors were encountered: