def test_data_dictionary_success(self, DD): vald = not_equal_to(1) df = _make_df([3, 3, 3], int) # using _call_data_dictionary assert vald._call_data_dictionary(DD, simple_attr("COL"), df["COL"]) is None # using __call__ assert vald(DD, simple_attr("COL"), df["COL"]) is None
def test_data_dictionary_fail(self, DD): vald = not_equal_to(1) df = _make_df([1, 1, 3], int) # using _call_data_dictionary with pytest.raises(ValueError) as call_dd: vald._call_data_dictionary(DD, simple_attr("COL"), df["COL"]) # using __call__ with pytest.raises(ValueError) as call: vald(DD, simple_attr("COL"), df["COL"]) assert call.value.args == call_dd.value.args assert call.value.args == ( "COL failed not_equal_to(value=1) validator 2 out of 3 rows.", )
def test_repr(self): assert repr(not_equal_to(1)) == "<not_equal_to(value=1) validator>"
def test_base_success(self): vald = not_equal_to(1) assert vald(None, simple_attr("test"), 2) is None
def test_base_fail(self): vald = not_equal_to(1) with pytest.raises(ValueError) as e: vald(None, simple_attr("test"), 1) assert e.value.args == ("test value of 1 does equal 1.",)