Python pandas.core.base.NoNewAttributesMixin() Examples

The following are 5 code examples of pandas.core.base.NoNewAttributesMixin(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pandas.core.base , or try the search function .
Example #1
Source File: test_base.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_mixin(self):
        class T(NoNewAttributesMixin):
            pass

        t = T()
        assert not hasattr(t, "__frozen")

        t.a = "test"
        assert t.a == "test"

        t._freeze()
        assert "__frozen" in dir(t)
        assert getattr(t, "__frozen")

        with pytest.raises(AttributeError):
            t.b = "test"

        assert not hasattr(t, "b") 
Example #2
Source File: test_base.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_mixin(self):
        class T(NoNewAttributesMixin):
            pass

        t = T()
        assert not hasattr(t, "__frozen")

        t.a = "test"
        assert t.a == "test"

        t._freeze()
        assert "__frozen" in dir(t)
        assert getattr(t, "__frozen")

        def f():
            t.b = "test"

        pytest.raises(AttributeError, f)
        assert not hasattr(t, "b") 
Example #3
Source File: test_base.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_mixin(self):
        class T(NoNewAttributesMixin):
            pass

        t = T()
        assert not hasattr(t, "__frozen")

        t.a = "test"
        assert t.a == "test"

        t._freeze()
        assert "__frozen" in dir(t)
        assert getattr(t, "__frozen")

        with pytest.raises(AttributeError):
            t.b = "test"

        assert not hasattr(t, "b") 
Example #4
Source File: test_base.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def test_mixin(self):
        class T(NoNewAttributesMixin):
            pass

        t = T()
        assert not hasattr(t, "__frozen")

        t.a = "test"
        assert t.a == "test"

        t._freeze()
        assert "__frozen" in dir(t)
        assert getattr(t, "__frozen")

        def f():
            t.b = "test"

        pytest.raises(AttributeError, f)
        assert not hasattr(t, "b") 
Example #5
Source File: test_base.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_mixin(self):
        class T(NoNewAttributesMixin):
            pass

        t = T()
        assert not hasattr(t, "__frozen")

        t.a = "test"
        assert t.a == "test"

        t._freeze()
        assert "__frozen" in dir(t)
        assert getattr(t, "__frozen")

        def f():
            t.b = "test"

        pytest.raises(AttributeError, f)
        assert not hasattr(t, "b")