Skip to content

Commit 0bc1909

Browse files
author
Sylvain MARIE
committed
Added test for the autodict/autorepr switch
1 parent c9bd3dc commit 0bc1909

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

autoclass/tests/features/test_autoclass.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def test_autoclass_pyfields():
106106
"""tests that @autoclass works with pyfields"""
107107
from pyfields import field
108108

109-
@autoclass
109+
@autoclass(autodict=False)
110110
class Foo(object):
111111
foo1 = field()
112112
foo2 = field(default=0)
@@ -127,3 +127,11 @@ class Bar(Foo):
127127

128128
# order in prints is the same than in init
129129
assert str(a) == "Bar(foo1='th', foo2=0, bar=2)"
130+
131+
# test autorepr
132+
f = Foo('a')
133+
assert str(f) == "Foo(foo1='a', foo2=0)"
134+
135+
# autodict was really disabled
136+
with pytest.raises(AttributeError):
137+
f.items()

0 commit comments

Comments
 (0)