class NullableModel(ndb.Model):
list_prop = ndb.StringProperty(repeated=True)
ord_prop = ndb.StringProperty()
# child3 = NullableStringProperty(repeated=True)
@pytest.mark.parametrize("changeset", [
["abc", u"абв"],
["", ""],
[u"", u""],
])
def test_repeated_string_property_none(changeset):
entity = NullableModel()
entity.list_prop = changeset
entity.ord_prop = ""
entity.put()
entity = entity.key.get()
assert entity.ord_prop == ""
assert entity.list_prop == changeset
assert entity.put()
============================= test session starts ==============================
platform darwin -- Python 2.7.16, pytest-4.6.9, py-1.8.1, pluggy-0.13.1 -- /Users/vladimir/Virtualenvs/py2-ndb-issue/bin/python2
cachedir: .pytest_cache
rootdir: /Users/vladimir/Projects/py2-ndb-issues, inifile: setup.cfg
plugins: env-0.6.2
collecting ... collected 4 items
test_get_multi.py::test_create_many_change_one_get_multi_all PASSED [ 25%]
test_get_multi.py::test_repeated_string_property_none[changeset0]
test_get_multi.py::test_repeated_string_property_none[changeset1] PASSED [ 50%]FAILED [ 75%]
test_get_multi.py:73 (test_repeated_string_property_none[changeset1])
[None, None] != ['', '']
Expected :['', '']
Actual :[None, None]
<Click to see difference>
changeset = ['', '']
@pytest.mark.parametrize("changeset", [
["abc", u"абв"],
["", ""],
[u"", u""],
])
def test_repeated_string_property_none(changeset):
entity = NullableModel()
entity.list_prop = changeset
entity.ord_prop = ""
entity.put()
entity = entity.key.get()
assert entity.ord_prop == ""
> assert entity.list_prop == changeset
E AssertionError: assert [None, None] == ['', '']
test_get_multi.py:87: AssertionError
FAILED [100%]
test_get_multi.py:73 (test_repeated_string_property_none[changeset2])
[None, None] != [u'', u'']
Expected :[u'', u'']
Actual :[None, None]
<Click to see difference>
changeset = ['', '']
@pytest.mark.parametrize("changeset", [
["abc", u"абв"],
["", ""],
[u"", u""],
])
def test_repeated_string_property_none(changeset):
entity = NullableModel()
entity.list_prop = changeset
entity.ord_prop = ""
entity.put()
entity = entity.key.get()
assert entity.ord_prop == ""
> assert entity.list_prop == changeset
E AssertionError: assert [None, None] == [u'', u'']
test_get_multi.py:87: AssertionError
Assertion failed
test_get_multi.py::test_repeated_string_property_none[changeset2]
The issue seems are in model.py#_entity_from_ds_entity and the following part of the method just in the end ** if sub_value else None **
Environment details
Google Cloud SDK 274.0.0
app-engine-python 1.9.87
app-engine-python-extras 1.9.87
beta 2019.05.17
bq 2.0.51
cloud-datastore-emulator 2.1.0
core 2019.12.17
gsutil 4.46
Steps to reproduce
Code example
Stack trace
The issue seems are in model.py#_entity_from_ds_entity and the following part of the method just in the end **
if sub_value else None**