Issue #83 resolved

Various errors in modeltests.serializers

Jason Chen
created an issue

{{{

!python

====================================================================== FAIL: Doctest: modeltests.serializers.models.test.API_TESTS


Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 2234, in runTest raise self.failureException(self.format_failure(new.getvalue())) AssertionError: Failed doctest test for modeltests.serializers.models.test.API_TESTS File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line unknown line number, in API_TESTS


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: for obj in serializers.deserialize("xml", xml): print(obj) Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test.API_TESTS[17]>", line 1, in <module> for obj in serializers.deserialize("xml", xml): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/xml_serializer.py", line 158, in next__ return self._handle_object(node) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/xml_serializer.py", line 167, in _handle_object Model = self._get_model_from_node(node, "model") File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/xml_serializer.py", line 269, in _get_model_from_node (node.nodeName, model_identifier)) django.core.serializers.base.DeserializationError: <object> node has invalid model identifier: 'b'serializers'.b'article''


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: objs = list(serializers.deserialize("xml", xml)) Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test.API_TESTS[19]>", line 1, in <module> objs = list(serializers.deserialize("xml", xml)) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/xml_serializer.py", line 158, in next__ return self._handle_object(node) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/xml_serializer.py", line 167, in _handle_object Model = self._get_model_from_node(node, "model") File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/xml_serializer.py", line 269, in _get_model_from_node (node.nodeName, model_identifier)) django.core.serializers.base.DeserializationError: <object> node has invalid model identifier: 'b'serializers'.b'article''


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: objs[0].save() Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test__.API_TESTS[21]>", line 1, in <module> objs[0].save() NameError: name 'objs' is not defined


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: Article.objects.all() Expected: [<Article: Poker has no place on television>, <Article: Time to reform copyright>] Got: [<Article: Poker has no place on ESPN>, <Article: Time to reform copyright>]


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: json Expected: '[{"pk": 2, "model": "serializers.category", "fields": {"name": "Music"}}]' Got: '[{"pk": 2, "model": "b\'serializers\'.b\'category\'", "fields": {"name": "Music"}}]'


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: for obj in serializers.deserialize("json", json): print(obj) Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test__.API_TESTS[29]>", line 1, in <module> for obj in serializers.deserialize("json", json): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/json.py", line 42, in Deserializer for obj in PythonDeserializer(simplejson.load(stream), **options): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 84, in Deserializer Model = _get_model(d["model"]) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 137, in _get_model raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier) django.core.serializers.base.DeserializationError: Invalid model identifier: 'b'serializers'.b'article''


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: for obj in serializers.deserialize("json", json): obj.save() Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test__.API_TESTS[31]>", line 1, in <module> for obj in serializers.deserialize("json", json): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/json.py", line 42, in Deserializer for obj in PythonDeserializer(simplejson.load(stream), **options): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 84, in Deserializer Model = _get_model(d["model"]) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 137, in _get_model raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier) django.core.serializers.base.DeserializationError: Invalid model identifier: 'b'serializers'.b'article''


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: Article.objects.all() Expected: [<Article: Just kidding; I love TV poker>, <Article: Time to reform copyright>] Got: [<Article: Poker has no place on ESPN>, <Article: Time to reform copyright>]


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: json Expected: '[{"pk": 1, "model": "serializers.authorprofile", "fields": {"date_of_birth": "1970-01-01"}}]' Got: '[{"pk": 1, "model": "b\'serializers\'.b\'authorprofile\'", "fields": {"date_of_birth": "1970-01-01"}}]'


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: for obj in serializers.deserialize("json", json): print(obj) Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test__.API_TESTS[37]>", line 1, in <module> for obj in serializers.deserialize("json", json): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/json.py", line 42, in Deserializer for obj in PythonDeserializer(simplejson.load(stream), **options): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 84, in Deserializer Model = _get_model(d["model"]) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 137, in _get_model raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier) django.core.serializers.base.DeserializationError: Invalid model identifier: 'b'serializers'.b'authorprofile''


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: print(serializers.serialize("json", Article.objects.all(), fields=('headline','pub_date'))) Expected: [{"pk": 1, "model": "serializers.article", "fields": {"headline": "Just kidding; I love TV poker", "pub_date": "2006-06-16 11:00:00"}}, {"pk": 2, "model": "serializers.article", "fields": {"headline": "Time to reform copyright", "pub_date": "2006-06-16 13:00:11"}}, {"pk": 3, "model": "serializers.article", "fields": {"headline": "Forward references pose no problem", "pub_date": "2006-06-16 15:00:00"}}] Got: [{"pk": 1, "model": "b'serializers'.b'article'", "fields": {"headline": "Poker has no place on ESPN", "pub_date": "2006-06-16 11:00:00"}}, {"pk": 2, "model": "b'serializers'.b'article'", "fields": {"headline": "Time to reform copyright", "pub_date": "2006-06-16 13:00:11"}}, {"pk": 3, "model": "b'serializers'.b'article'", "fields": {"headline": "Forward references pose no problem", "pub_date": "2006-06-16 15:00:00"}}]


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: print(serializers.serialize("json", [mv])) Expected: [{"pk": 1, "model": "serializers.movie", "fields": {"price": "0.00", "actor": "Zażółć", "title": "Gęślą jaźń"}}] Got: [{"pk": 1, "model": "b'serializers'.b'movie'", "fields": {"price": "0.00", "actor": "Za\u017c\u00f3\u0142\u0107", "title": "G\u0119\u015bl\u0105 ja\u017a\u0144"}}]


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: list(serializers.deserialize('json', serializers.serialize('json', [mv])))[0].object.title Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test__.API_TESTS[54]>", line 1, in <module> list(serializers.deserialize('json', serializers.serialize('json', [mv])))[0].object.title File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/json.py", line 42, in Deserializer for obj in PythonDeserializer(simplejson.load(stream), **options): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 84, in Deserializer Model = _get_model(d["model"]) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 137, in _get_model raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier) django.core.serializers.base.DeserializationError: Invalid model identifier: 'b'serializers'.b'movie''


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: print(serializers.serialize("json", [mv2])) Expected: [{"pk": null, "model": "serializers.movie", "fields": {"price": "0.00", "actor": "Zażółć", "title": "Movie 2"}}] Got: [{"pk": null, "model": "b'serializers'.b'movie'", "fields": {"price": "0.00", "actor": "Za\u017c\u00f3\u0142\u0107", "title": "Movie 2"}}]


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: print(list(serializers.deserialize('json', serializers.serialize('json', [mv2])))[0].object.id) Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test__.API_TESTS[57]>", line 1, in <module> print(list(serializers.deserialize('json', serializers.serialize('json', [mv2])))[0].object.id) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/json.py", line 42, in Deserializer for obj in PythonDeserializer(simplejson.load(stream), **options): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 84, in Deserializer Model = _get_model(d["model"]) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 137, in _get_model raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier) django.core.serializers.base.DeserializationError: Invalid model identifier: 'b'serializers'.b'movie''


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: print(serializers.serialize("json", [sc])) Expected: [{"pk": null, "model": "serializers.score", "fields": {"score": 3.4}}] Got: [{"pk": null, "model": "b'serializers'.b'score'", "fields": {"score": 3.4}}]


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: print(list(serializers.deserialize('json', serializers.serialize('json', [sc])))[0].object.score) Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test__.API_TESTS[60]>", line 1, in <module> print(list(serializers.deserialize('json', serializers.serialize('json', [sc])))[0].object.score) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/json.py", line 42, in Deserializer for obj in PythonDeserializer(simplejson.load(stream), **options): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 84, in Deserializer Model = _get_model(d["model"]) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 137, in _get_model raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier) django.core.serializers.base.DeserializationError: Invalid model identifier: 'b'serializers'.b'score''


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: print(serialized) Expected: [{"pk": 1, "model": "serializers.player", "fields": {"name": "Soslan Djanaev", "rank": 1, "team": "Spartak Moskva"}}] Got: [{"pk": 1, "model": "b'serializers'.b'player'", "fields": {"name": "Soslan Djanaev", "rank": 1, "team": "Spartak Moskva"}}]


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: obj = list(serializers.deserialize("json", serialized))[0] Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test__.API_TESTS[68]>", line 1, in <module> obj = list(serializers.deserialize("json", serialized))[0] File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/json.py", line 42, in Deserializer for obj in PythonDeserializer(simplejson.load(stream), **options): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 84, in Deserializer Model = _get_model(d["model"]) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 137, in _get_model raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier) django.core.serializers.base.DeserializationError: Invalid model identifier: 'b'serializers'.b'player''


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: print(obj) Expected: <DeserializedObject: serializers.Player(pk=1)> Got: <DeserializedObject: serializers.Author(pk=4)>


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: print(serialized) Expected: [{"pk": 4, "model": "serializers.article", "fields": {"headline": "Nobody remembers the early years", "pub_date": "0001-02-03 04:05:06", "categories": [], "author": 2}}] Got: [{"pk": 4, "model": "b'serializers'.b'article'", "fields": {"headline": "Nobody remembers the early years", "pub_date": "0001-02-03 04:05:06", "categories": [], "author": 2}}]


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: obj = list(serializers.deserialize("json", serialized))[0] Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test__.API_TESTS[73]>", line 1, in <module> obj = list(serializers.deserialize("json", serialized))[0] File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/json.py", line 42, in Deserializer for obj in PythonDeserializer(simplejson.load(stream), **options): File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 84, in Deserializer Model = _get_model(d["model"]) File "/usr/local/lib/python3.1/dist-packages/django/core/serializers/python.py", line 137, in _get_model raise base.DeserializationError("Invalid model identifier: '%s'" % model_identifier) django.core.serializers.base.DeserializationError: Invalid model identifier: 'b'serializers'.b'article''


File "/home/jason/Desktop/workspace/django-3k/build/tests/modeltests/serializers/models.py", line ?, in modeltests.serializers.models.test.API_TESTS Failed example: print(obj.object.pub_date) Exception raised: Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 1307, in run compileflags, 1), test.globs) File "<doctest modeltests.serializers.models.test__.API_TESTS[74]>", line 1, in <module> print(obj.object.pub_date) AttributeError: 'Author' object has no attribute 'pub_date'

}}}

Comments (2)

  1. Jason Chen reporter

    From what I understand so far, all failures have something to do with strings of the form:

    "'b'serializers'.b'article''"
    

    Note the multiple layers of quotes, with byte string b'blah' separated by a "." in the middle, converting through django/core/serializers/xml_serializers.py is the best course of action, but there ought to be better ways to fix this problem, more research is needed for that.

  2. Log in to comment