test_validate.py 668 B

1234567891011121314151617181920212223242526
  1. import pytest
  2. @pytest.mark.parametrize(
  3. "func",
  4. [
  5. "reset_index",
  6. "_set_name",
  7. "sort_values",
  8. "sort_index",
  9. "rename",
  10. "dropna",
  11. "drop_duplicates",
  12. ],
  13. )
  14. @pytest.mark.parametrize("inplace", [1, "True", [1, 2, 3], 5.0])
  15. def test_validate_bool_args(string_series, func, inplace):
  16. """Tests for error handling related to data types of method arguments."""
  17. msg = 'For argument "inplace" expected type bool'
  18. kwargs = {"inplace": inplace}
  19. if func == "_set_name":
  20. kwargs["name"] = "hello"
  21. with pytest.raises(ValueError, match=msg):
  22. getattr(string_series, func)(**kwargs)