PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 276 - Point tests fail with Python 2.7
: Point tests fail with Python 2.7
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: Shiboken
: HEAD
: All All
: P5 normal
Assigned To: Marcelo Lira
:
:
:
  Show dependency treegraph
 
Reported: 2010-08-02 13:13 EEST by Kalev Lember
Modified: 2010-09-10 19:21 EEST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kalev Lember 2010-08-02 13:13:30 EEST
In Python 2.7 assertNotEqual is defined using != operator:

    def assertNotEqual(self, first, second, msg=None):
        """Fail if the two objects are equal as determined by the '=='
           operator.
        """
        if not first != second:
            msg = self._formatMessage(msg, '%s == %s' % (safe_repr(first),
                                                          safe_repr(second)))
            raise self.failureException(msg)


Point class in Shiboken tests/libsample/ deliberately doesn't define !=
operator to test for the absense of the __ne__ method in the Python binding.
However, the absence of != operator also makes tests which use assertNotEqual()
fail with Python 2.7.

test 32
      Start 32: class_fields

32: Test command: /bin/sh
/home/kalev/git/shiboken/master/shiboken-0.3.2/tests/run_test.sh
/home/kalev/git/shiboken/master/shiboken-0.3.2/i386-redhat-linux-gnu/tests/libsample:/home/kalev/git/shiboken/master/shiboken-0.3.2/i386-redhat-linux-gnu/libshiboken
/home/kalev/git/shiboken/master/shiboken-0.3.2/i386-redhat-linux-gnu/tests/samplebinding:/home/kalev/git/shiboken/master/shiboken-0.3.2/i386-redhat-linux-gnu/tests/otherbinding
/usr/bin/python
/home/kalev/git/shiboken/master/shiboken-0.3.2/tests/samplebinding/class_fields_test.py
32: Test timeout computed to be: 5
32: ..E..
32: ======================================================================
32: ERROR: testAccessingValueTypeField (__main__.TestAccessingCppFields)
32: Reads and writes a value type (in this case a 'Point') field.
32: ----------------------------------------------------------------------
32: Traceback (most recent call last):
32:   File
"/home/kalev/git/shiboken/master/shiboken-0.3.2/tests/samplebinding/class_fields_test.py",
line 67, in testAccessingValueTypeField
32:     self.assertNotEqual(d.valueTypeField, old_value)
32:   File "/usr/lib/python2.7/unittest/case.py", line 500, in assertNotEqual
32:     if not first != second:
32: NotImplementedError: operator not implemented.
32:
32: ----------------------------------------------------------------------
32: Ran 5 tests in 0.003s
32:
32: FAILED (errors=1)
32/76 Test #32: class_fields
.................................................***Failed    0.11 sec



test 57
      Start 57: point

57: Test command: /bin/sh
/home/kalev/git/shiboken/master/shiboken-0.3.2/tests/run_test.sh
/home/kalev/git/shiboken/master/shiboken-0.3.2/i386-redhat-linux-gnu/tests/libsample:/home/kalev/git/shiboken/master/shiboken-0.3.2/i386-redhat-linux-gnu/libshiboken
/home/kalev/git/shiboken/master/shiboken-0.3.2/i386-redhat-linux-gnu/tests/samplebinding:/home/kalev/git/shiboken/master/shiboken-0.3.2/i386-redhat-linux-gnu/tests/otherbinding
/usr/bin/python
/home/kalev/git/shiboken/master/shiboken-0.3.2/tests/samplebinding/point_test.py
57: Test timeout computed to be: 5
57: ......E
57: ======================================================================
57: ERROR: testReturnNewCopy (__main__.PointTest)
57: Point returns a copy of itself.
57: ----------------------------------------------------------------------
57: Traceback (most recent call last):
57:   File
"/home/kalev/git/shiboken/master/shiboken-0.3.2/tests/samplebinding/point_test.py",
line 70, in testReturnNewCopy
57:     self.assertNotEqual(pt1, pt2)
57:   File "/usr/lib/python2.7/unittest/case.py", line 500, in assertNotEqual
57:     if not first != second:
57: NotImplementedError: operator not implemented.
57: 
57: ----------------------------------------------------------------------
57: Ran 7 tests in 0.002s
57: 
57: FAILED (errors=1)
57/76 Test #57: point
........................................................***Failed    0.12 sec
Comment 1 renato filho 2010-08-02 18:04:47 EEST
Fixed on commit:

commit ce4b5f535f43bd2ff800b709f88c6f9c5be68003
Author: Renato Filho <renato.filho@openbossa.org>
Date:   Mon Aug 2 17:39:00 2010 -0300
Comment 2 Kalev Lember 2010-08-04 07:46:54 EEST
Sorry, I missed one more place where assertNotEqual is used. 

Can you change reference_test.py:67 to use assert_(not a == b) similar to
83c272?


18: Test command: /bin/sh
/home/kalev/git/pyside/shiboken/master/shiboken-0.4.0/tests/run_test.sh
/home/kalev/git/pyside/shiboken/master/shiboken-0.4.0/i686-redhat-linux-gnu/tests/libsample:/home/kalev/git/pyside/shiboken/master/shiboken-0.4.0/i686-redhat-linux-gnu/tests/libother:/home/kalev/git/pyside/shiboken/master/shiboken-0.4.0/i686-redhat-linux-gnu/libshiboken
/home/kalev/git/pyside/shiboken/master/shiboken-0.4.0/i686-redhat-linux-gnu/tests/samplebinding:/home/kalev/git/pyside/shiboken/master/shiboken-0.4.0/i686-redhat-linux-gnu/tests/otherbinding
/usr/bin/python
/home/kalev/git/pyside/shiboken/master/shiboken-0.4.0/tests/samplebinding/reference_test.py
18: Test timeout computed to be: 60
18: E.......
18: ======================================================================
18: ERROR: testCantSegFaultWhenReceiveNone (__main__.ReferenceTest)
18: do not segfault when receiving None as argument.
18: ----------------------------------------------------------------------
18: Traceback (most recent call last):
18:   File
"/home/kalev/git/pyside/shiboken/master/shiboken-0.4.0/tests/samplebinding/reference_test.py",
line 67, in testCantSegFaultWhenReceiveNone
18:     self.assertNotEqual(None, s)
18:   File "/usr/lib/python2.7/unittest/case.py", line 500, in assertNotEqual
18:     if not first != second:
18: NotImplementedError: operator not implemented.
18: 
18: ----------------------------------------------------------------------
18: Ran 8 tests in 0.003s
18: 
18: FAILED (errors=1)
18/81 Test #18: reference
....................................................***Failed    0.15 sec

You changed most of the places which used ssertNotEqual to 
- self.assertNotEqual(pt1, pt2)
+ self.assert_(not pt1 == pt2)

18: Traceback (most recent call last):
18:   File
"/home/kalev/git/pyside/shiboken/master/shiboken-0.4.0/tests/samplebinding/reference_test.py",
line 67, in testCantSegFaultWhenReceiveNone
18:     self.assertNotEqual(None, s)
18:   File "/usr/lib/python2.7/unittest/case.py", line 500, in assertNotEqual
18:     if not first != second:
18: NotImplementedError: operator not implemented.
Comment 3 Kalev Lember 2010-08-04 08:21:10 EEST
Merge request: http://qt.gitorious.org/pyside/shiboken/merge_requests/177
Comment 4 renato filho 2010-08-04 18:21:44 EEST
merge request accept and merged