一直很喜欢 nose 的 assert,方法多样,后来打算把所有的用例全部转换成 pytest,而 pytest 的 assert,相较于 nose,感觉太单调了,再者如果要是直接修改用例这部分的 assert,改动有点多,比较懒,直接抄袭 nose 的 assert 过来给 pytest 用。 看了下 nose 的 assert,来自 nose.tools,扫了下 tools 目录下的源码,继...
assert_almost_equal(field.deserialize(12.3), 12.3) assert math.isclose(field.deserialize("12.3"), 12.3) assert math.isclose(field.deserialize(12.3), 12.3) @pytest.mark.parametrize("in_val", ["bad", "", {}]) def test_invalid_float_field_deserialization(self, in_val): @@ -980,7 +979...
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, ...
The pytest third-party library is a popular testing framework in Python. 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 ...
assert_series_equal(result, expected)else:assert_almost_equal(result, expected[0]) cp = ts.copy() cp[date] =0expected = Series(np.where(mask,0, ts), index=ts.index) assert_series_equal(cp, expected) pytest.raises(KeyError, ts.__getitem__, datetime(2000,1,6))# new indexts[datetime...
tm.assert_almost_equal(df.values, values)withpytest.raises(TypeError, match='boolean values only'): df[df *0] =2 開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:27,代碼來源:test_setitem.py 示例13: check_values ▲點讚 6▼ # 需要導入模塊: from pandas.util import testing [as 別名]# 或者...
assert_almost_equal(actual_phase_offset, phase_offset) assert cp.name == 'a_b_phase' xrt.assert_equal(xrft.cross_phase(da1, da2), cp) with pytest.raises(ValueError): xrft.cross_phase(da1, da2.isel(x=0).drop('x')) with pytest.raises(ValueError): xrft.cross_phase(da1, da2....
assert_categorical_equal(cat, new) assert res is None # removal is not in categories def f(): cat.remove_categories(["c"]) pytest.raises(ValueError, f) 浏览完整代码 来源:test_api.py 项目:mficek/pandas 示例13 def test_basic(self): # run multiple times here for n in range(10): ...
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): 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...