resolve get() giving wrong value in modeltests.basic

Issue #7 resolved
Johan Harjono
created an issue

current error message

{{{

!pycon

File "/home/johan/workspace/fiji/build/tests/modeltests/basic/models.py", line ?, in modeltests.basic.models.test.API_TESTS Failed example: Article.objects.get(pk=a.id).headline Expected: u'林原 めぐみ' Got: 'Area woman programs in Python' }}}

Comments (9)

  1. Maxim Mai

    something interesting came up when I was working to resolve my "FieldDoesntExist" error,

    in

    File "/Users/maxim/Dropbox/workspace/django-3k/build/tests/modeltests/basic/models.py", line ?, in modeltests.basic.models.__test__.API_TESTS
    Failed example:
        Article.objects.get(id__exact=2)
    Expected:
        Traceback (most recent call last):
            ...
        DoesNotExist: Article matching query does not exist.
    Got:
        Traceback (most recent call last):
          File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages/django/test/_doctest.py", line 1275, in __run
            compileflags, 1), test.globs)
          File "<doctest modeltests.basic.models.__test__.API_TESTS[24]>", line 1, in <module>
            Article.objects.get(id__exact=2)
          File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages/django/db/models/manager.py", line 132, in get
            return self.get_query_set().get(*args, **kwargs)
          File "/Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages/django/db/models/query.py", line 339, in get
            % self.model._meta.object_name)
        modeltests.basic.models.DoesNotExist: Article matching query does not exist.
    

    refer to Martin's comment, the error is indeed expected, but why Python 3 generates the error in different ways, namely,

    originally, we expect:

    DoesNotExist: Article matching query does not exist.
    

    but now we get something:

    modeltests.basic.models.DoesNotExist: Article matching query does not exist.
    

    and Johan mentioned that possibly it's because there are 2 exception classes created.

  2. Johan Harjono reporter

    I must admit I'm skeptical that the FieldDoesNotExist error could affect get() seeing as get() should not raise any exception at all (in fact it does return a value! just the wrong one)

    This is all conjecture at this point and actual debugging should be done by the owner of this ticket to verify the root of the problem

  3. Nate Margono

    attempted to debug -- the values seemed to be correct throughout following debugger with id=1 and column as "pk", but in the end the "got"-value is still the wrong one. i suspect the problem lies when it tries to order the tuples, so the wanted output is switched out of its position. will debug some more tonight.

  4. Log in to comment