MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_json

Method test_json

test/ext/test_indexable.py:65–82  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

63 assert_raises(IndexError, setattr, a2, "fifth", 10)
64
65 def test_json(self):
66 Base = declarative_base()
67
68 class J(Base):
69 __tablename__ = "j"
70 id = Column("id", Integer, primary_key=True)
71 json = Column("_json", JSON, default={})
72 field = index_property("json", "field")
73
74 j = J(json={"a": 1, "b": 2})
75 assert_raises(AttributeError, lambda: j.field)
76 j.field = "test"
77 eq_(j.field, "test")
78 eq_(j.json, {"a": 1, "b": 2, "field": "test"})
79
80 j2 = J(field="test")
81 eq_(j2.json, {"field": "test"})
82 eq_(j2.field, "test")
83
84 def test_value_is_none_attributeerror(self):
85 Base = declarative_base()

Callers

nothing calls this directly

Calls 4

declarative_baseFunction · 0.90
assert_raisesFunction · 0.90
eq_Function · 0.90
JClass · 0.85

Tested by

no test coverage detected