Exemplo n.º 1
0
    def test_accessor_works(self):
        register_series_accessor("test")(CustomAccessor)

        s = ps.Series([1, 2])
        assert s.test.obj is s
        assert s.test.prop == "item"
        assert s.test.method() == "item"
Exemplo n.º 2
0
 def test_overwrite_warns(self):
     mean = ps.Series.mean
     try:
         with assert_produces_warning(UserWarning, raise_on_extra_warnings=False) as w:
             register_series_accessor("mean")(CustomAccessor)
             s = ps.Series([1, 2])
             assert s.mean.prop == "item"
         msg = str(w[0].message)
         assert "mean" in msg
         assert "CustomAccessor" in msg
         assert "Series" in msg
     finally:
         ps.Series.mean = mean
Exemplo n.º 3
0
 def test_series_register(self):
     with ensure_removed(ps.Series, "test"):
         register_series_accessor("test")(CustomAccessor)
         assert self.psdf.a.test.prop == "item"
         assert self.psdf.a.test.method() == "item"
         assert self.psdf.a.test.check_length() == len(self.psdf["a"])