~ubuntu-branches/ubuntu/karmic/python3.0/karmic

« back to all changes in this revision

Viewing changes to Lib/test/test_contains.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-16 17:18:23 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090216171823-1d5cm5qnnjvmnzzm
Tags: 3.0.1-0ubuntu1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
            This class is designed to make sure that the contains code
57
57
            works when the list is modified during the check.
58
58
            """
59
 
            aList = range(15)
60
 
            def __cmp__(self, other):
 
59
            aList = list(range(15))
 
60
            def __eq__(self, other):
61
61
                if other == 12:
62
62
                    self.aList.remove(12)
63
63
                    self.aList.remove(13)
64
64
                    self.aList.remove(14)
65
 
                return 1
 
65
                return 0
66
66
 
67
67
        self.assert_(Deviant1() not in Deviant1.aList)
68
68
 
69
 
        class Deviant2:
70
 
            """Behaves strangely when compared
71
 
 
72
 
            This class raises an exception during comparison.  That in
73
 
            turn causes the comparison to fail with a TypeError.
74
 
            """
75
 
            def __cmp__(self, other):
76
 
                if other == 4:
77
 
                    raise RuntimeError("gotcha")
78
 
 
79
 
        try:
80
 
            self.assert_(Deviant2() not in a)
81
 
        except TypeError:
82
 
            pass
83
 
 
84
69
    def test_nonreflexive(self):
85
70
        # containment and equality tests involving elements that are
86
71
        # not necessarily equal to themselves