resolve failure with TypeError in modeltests/one_to_one

Create issue
Issue #48 wontfix
c4nhukha created an issue

{{{ #!python

File "/home/andrew/django-3k/build/tests/modeltests/one_to_one/", line ?, in modeltests.one_to_one.models.test.API_TESTS Failed example: try: MultiModel(link1=p2, link2=o1, name="x1").save() except Exception as e: if isinstance(e, IntegrityError): print("Pass") else: print("Fail with %s" % type(e)) Expected: Pass Got: Fail with <class 'TypeError'> }}}

Comments (5)

  1. c4nhukha reporter
    • changed status to open

    The error occurs in at:

    got = self._fakeout.getvalue()  # the actual output

    It then calls:

    class _SpoofOut(StringIO):
        def getvalue(self):
            result = StringIO.getvalue(self) #this is wh

    The value of self is "_SpoofOut: <django.test._doctest._SpoofOut object at 0x29c9ed0>"

  2. c4nhukha reporter

    in python2.6:
    result is: "str: Pass\n"
    self is: "_SpoofOut: <django.test._doctest._SpoofOut instance at 0x197dab8>"
    self.buf is: "str: Pass\n"

    in python3.1:
    result is: "str: Fail with <class 'TypeError'>\n"
    self is: "_SpoofOut: <django.test._doctest._SpoofOut object at 0x3447cd0>"
    there's no self.buf field.

  3. c4nhukha reporter

    The difference between python2.6 and python3.1 is that python2.6 uses StringIO.StringIO.getvalue() while, the python3.1 uses IO.StringIO.getvalue(). However, these 2 functionalities should work the same way. The value of "self" seems to be similar for passing cases as well as this failing case.

  4. c4nhukha reporter

    I still can't figure out why this error occurred. The value of self is a "_SpoofOut" object, which previous passing cases are of the same type. But for some reason, it only fails when "MultiModel(link1=p2, link2=o1, name="x1").save()" is called.

    I've requested help from Joel for this problem.

  5. Log in to comment