Issue #56 resolved

Problem with representation of output in modeltests.m2m_signals

Johan Harjono
created an issue

{{{

!python

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


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


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: c1.default_parts.add(p1, p2, p3) Expected: m2m_changed signal instance: VW action: add reverse: False model: <class 'modeltests.m2m_signals.models.Part'> objects: [<Part: Doors>, <Part: Engine>, <Part: Wheelset>] Got: m2m_changed signal ('instance:', <Car: VW>) ('action:', 'add') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Part'>) ('objects:', [<Part: Doors>, <Part: Engine>, <Part: Wheelset>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: p2.car_set.add(c2, c3) Expected: m2m_changed signal instance: Doors action: add reverse: True model: <class 'modeltests.m2m_signals.models.Car'> objects: [<Car: BMW>, <Car: Toyota>] Got: m2m_changed signal ('instance:', <Part: Doors>) ('action:', 'add') ('reverse:', True) ('model:', <class 'modeltests.m2m_signals.models.Car'>) ('objects:', [<Car: BMW>, <Car: Toyota>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: c1.default_parts.remove(p3, p4) Expected: m2m_changed signal instance: VW action: remove reverse: False model: <class 'modeltests.m2m_signals.models.Part'> objects: [<Part: Airbag>, <Part: Engine>] Got: m2m_changed signal ('instance:', <Car: VW>) ('action:', 'remove') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Part'>) ('objects:', [<Part: Airbag>, <Part: Engine>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: c1.optional_parts.add(p4,p5) Expected: m2m_changed signal instance: VW action: add reverse: False model: <class 'modeltests.m2m_signals.models.Part'> objects: [<Part: Airbag>, <Part: Sunroof>] Got: m2m_changed signal ('instance:', <Car: VW>) ('action:', 'add') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Part'>) ('objects:', [<Part: Airbag>, <Part: Sunroof>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: p4.cars_optional.add(c1, c2, c3) Expected: m2m_changed signal instance: Airbag action: add reverse: True model: <class 'modeltests.m2m_signals.models.Car'> objects: [<Car: BMW>, <Car: Toyota>] Got: m2m_changed signal ('instance:', <Part: Airbag>) ('action:', 'add') ('reverse:', True) ('model:', <class 'modeltests.m2m_signals.models.Car'>) ('objects:', [<Car: BMW>, <Car: Toyota>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: p4.cars_optional.remove(c1) Expected: m2m_changed signal instance: Airbag action: remove reverse: True model: <class 'modeltests.m2m_signals.models.Car'> objects: [<Car: VW>] Got: m2m_changed signal ('instance:', <Part: Airbag>) ('action:', 'remove') ('reverse:', True) ('model:', <class 'modeltests.m2m_signals.models.Car'>) ('objects:', [<Car: VW>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: c1.default_parts.clear() Expected: m2m_changed signal instance: VW action: clear reverse: False model: <class 'modeltests.m2m_signals.models.Part'> Got: m2m_changed signal ('instance:', <Car: VW>) ('action:', 'clear') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Part'>)


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: p2.car_set.clear() Expected: m2m_changed signal instance: Doors action: clear reverse: True model: <class 'modeltests.m2m_signals.models.Car'> Got: m2m_changed signal ('instance:', <Part: Doors>) ('action:', 'clear') ('reverse:', True) ('model:', <class 'modeltests.m2m_signals.models.Car'>)


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: p4.cars_optional.clear() Expected: m2m_changed signal instance: Airbag action: clear reverse: True model: <class 'modeltests.m2m_signals.models.Car'> Got: m2m_changed signal ('instance:', <Part: Airbag>) ('action:', 'clear') ('reverse:', True) ('model:', <class 'modeltests.m2m_signals.models.Car'>)


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: c1.default_parts.create(name='Windows') Expected: m2m_changed signal instance: VW action: add reverse: False model: <class 'modeltests.m2m_signals.models.Part'> objects: [<Part: Windows>] <Part: Windows> Got: m2m_changed signal ('instance:', <Car: VW>) ('action:', 'add') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Part'>) ('objects:', [<Part: Windows>]) <Part: Windows>


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: c1.default_parts = [p1,p2,p3] Expected: m2m_changed signal instance: VW action: clear reverse: False model: <class 'modeltests.m2m_signals.models.Part'> m2m_changed signal instance: VW action: add reverse: False model: <class 'modeltests.m2m_signals.models.Part'> objects: [<Part: Doors>, <Part: Engine>, <Part: Wheelset>] Got: m2m_changed signal ('instance:', <Car: VW>) ('action:', 'clear') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Part'>) m2m_changed signal ('instance:', <Car: VW>) ('action:', 'add') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Part'>) ('objects:', [<Part: Doors>, <Part: Engine>, <Part: Wheelset>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: c4.default_parts = [p2] Expected: m2m_changed signal instance: Bugatti action: clear reverse: False model: <class 'modeltests.m2m_signals.models.Part'> m2m_changed signal instance: Bugatti action: add reverse: False model: <class 'modeltests.m2m_signals.models.Part'> objects: [<Part: Doors>] Got: m2m_changed signal ('instance:', <SportsCar: Bugatti>) ('action:', 'clear') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Part'>) m2m_changed signal ('instance:', <SportsCar: Bugatti>) ('action:', 'add') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Part'>) ('objects:', [<Part: Doors>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: p3.car_set.add(c4) Expected: m2m_changed signal instance: Engine action: add reverse: True model: <class 'modeltests.m2m_signals.models.Car'> objects: [<Car: Bugatti>] Got: m2m_changed signal ('instance:', <Part: Engine>) ('action:', 'add') ('reverse:', True) ('model:', <class 'modeltests.m2m_signals.models.Car'>) ('objects:', [<Car: Bugatti>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: p1.friends = [p2, p3] Expected: m2m_changed signal instance: Alice action: clear reverse: False model: <class 'modeltests.m2m_signals.models.Person'> m2m_changed signal instance: Alice action: add reverse: False model: <class 'modeltests.m2m_signals.models.Person'> objects: [<Person: Bob>, <Person: Chuck>] Got: m2m_changed signal ('instance:', <Person: Alice>) ('action:', 'clear') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Person'>) m2m_changed signal ('instance:', <Person: Alice>) ('action:', 'add') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Person'>) ('objects:', [<Person: Bob>, <Person: Chuck>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: p1.fans = [p4] Expected: m2m_changed signal instance: Alice action: clear reverse: False model: <class 'modeltests.m2m_signals.models.Person'> m2m_changed signal instance: Alice action: add reverse: False model: <class 'modeltests.m2m_signals.models.Person'> objects: [<Person: Daisy>] Got: m2m_changed signal ('instance:', <Person: Alice>) ('action:', 'clear') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Person'>) m2m_changed signal ('instance:', <Person: Alice>) ('action:', 'add') ('reverse:', False) ('model:', <class 'modeltests.m2m_signals.models.Person'>) ('objects:', [<Person: Daisy>])


File "/home/johan/workspace/fiji/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.test.API_TESTS Failed example: p3.idols = [p1,p2] Expected: m2m_changed signal instance: Chuck action: clear reverse: True model: <class 'modeltests.m2m_signals.models.Person'> m2m_changed signal instance: Chuck action: add reverse: True model: <class 'modeltests.m2m_signals.models.Person'> objects: [<Person: Alice>, <Person: Bob>] Got: m2m_changed signal ('instance:', <Person: Chuck>) ('action:', 'clear') ('reverse:', True) ('model:', <class 'modeltests.m2m_signals.models.Person'>) m2m_changed signal ('instance:', <Person: Chuck>) ('action:', 'add') ('reverse:', True) ('model:', <class 'modeltests.m2m_signals.models.Person'>) ('objects:', [<Person: Alice>, <Person: Bob>])


Ran 1 test in 0.122s

FAILED (failures=1)

}}}

Comments (7)

  1. Johan Harjono reporter

    just looking at it, I would say it's an issue with repr which perhaps could be fixed on displayhook, but it seems rather arduous and specific to this instance, hmm...

  2. Joel Crocker

    Many fewer doctest failures now. Running b0ca41f3c203 .

    ======================================================================
    FAIL: Doctest: modeltests.m2m_signals.models.__test__.API_TESTS
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/usr/local/lib/python3.1/dist-packages/django/test/_doctest.py", line 2254, in runTest
        raise self.failureException(self.format_failure(new.getvalue()))
    AssertionError: Failed doctest test for modeltests.m2m_signals.models.__test__.API_TESTS
      File "/home/joel/workspace/django-3k/build/tests/modeltests/m2m_signals/models.py", line unknown line number, in API_TESTS
    
    ----------------------------------------------------------------------
    File "/home/joel/workspace/django-3k/build/tests/modeltests/m2m_signals/models.py", line ?, in modeltests.m2m_signals.models.__test__.API_TESTS
    Failed example:
        c1.default_parts.create(name='Windows')
    Expected:
        m2m_changed signal
        instance: VW
        action: add
        reverse: False
        model: <class 'modeltests.m2m_signals.models.Part'>
        objects: [<Part: Windows>]
        <Part: Windows>
    Got:
        m2m_changed signal
        instance: VW
        action: add
        reverse: False
        model: <class 'modeltests.m2m_signals.models.Part'>
        objects: [<Part: Windows>]
    
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.140s
    
    FAILED (failures=1)
    
  3. Joel Crocker

    Somehow the __repr__() method of the Part object returned by create() is not outputting anything. This causes the doctest to fail. It seems clear that the Part does get created, as its __repr__() is being called successfully in order to print the list of objects for this test case.

  4. Joel Crocker

    This test passes if the line:

    c1.default_parts.create(name='Windows')
    

    is switched to:

    print(c1.default_parts.create(name='Windows').__repr__())
    

    In other words, it appears that the result of __repr__() is not being output during the doctest as would be expected.

    This change could be made to the original Python 2.x test case code, but it doesn't seem right to change the doctest just to make this test pass. It really seems that the Python 3.x code should be working, and yet it isn't.

  5. Log in to comment