本文整理汇总了Python中pandas.core.base.NoNewAttributesMixin方法的典型用法代码示例。如果您正苦于以下问题:Python base.NoNewAttributesMixin方法的具体用法?Python base.NoNewAttributesMixin怎么用?Python base.NoNewAttributesMixin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.core.base
的用法示例。
在下文中一共展示了base.NoNewAttributesMixin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mixin
# 需要导入模块: from pandas.core import base [as 别名]
# 或者: from pandas.core.base import NoNewAttributesMixin [as 别名]
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")
示例2: test_mixin
# 需要导入模块: from pandas.core import base [as 别名]
# 或者: from pandas.core.base import NoNewAttributesMixin [as 别名]
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")