At its core, you’ll find the assert statement, which you can use to write most of your test cases in pytest.Here are a few examples of writing test cases using assert statements. The examples below take advantage of some built-in functions, which provide the testing material:Python test_...
This PR refactors the testing methods in the codebase(integration tests directory) by replacing thenp.testing.assert_array_almost_equalmethod withnp.testing.assert_allclosefor better precision and flexibility in comparison. Related to#4488 Type of change )...
assert_array_almost_equal(ind_X, ind_D) # Must raise a ValueError if the matrix is not of correct shape assert_raises(ValueError, getattr(nbrs_D, method), X) with pytest.raises(ValueError): getattr(nbrs_D, method)(X) target = np.arange(X.shape[0]) for Est in estimators: @@ -295...
with pytest.raises(ValueError): BaggingClassifier(base, max_features="foobar").fit(X, y) # Test support of decision_function assert not hasattr(BaggingClassifier(base).fit(X, y), 'decision_function') @@ -484,11 +481,13 @@ def test_parallel_classification(): assert_array_almost_equal(decis...
with pytest.raises(ValueError): est.fit(X, y) est = DummyRegressor(strategy="quantile", quantile=1.1) assert_raises(ValueError, est.fit, X, y) with pytest.raises(ValueError): est.fit(X, y) est = DummyRegressor(strategy="quantile", quantile='abc') assert_raises(TypeError, est.fit, X, ...
with pytest.raises(ValueError): cv(n_repeats=1.5) @pytest.mark.parametrize( @@ -954,7 +963,8 @@ def test_repeated_kfold_determinstic_split(): assert_array_equal(train, [2, 3, 4]) assert_array_equal(test, [0, 1]) assert_raises(StopIteration, next, splits) with pytest.raises(Stop...