def testKeepUnsorted(self):
    """An imperfect test that insort triggers ExceptionWithContext.__cmp__."""
    # If ExceptionWithContext.__cmp__ doesn't trigger TypeError in
    # bisect.insort then the default comparison of object id will be used. The
    # id values tend to be given out in order of creation so call
    # problems._Report with objects in a different order. This test should
    # break if ExceptionWithContext.__cmp__ is removed or changed to return 0
    # or cmp(id(self), id(y)).
    exceptions = []
    for i in range(20):
      exceptions.append(transitfeed.OtherProblem(description="e%i" % i))
    exceptions = exceptions[10:] + exceptions[:10]
    self.problems = self.CreateLimitPerTypeProblemReporter(3)
    self.accumulator = self.problems.GetAccumulator()
    for e in exceptions:
      self.problems.AddToAccumulator(e)

    self.assertEquals(0, self.accumulator.WarningCount())
    self.assertEquals(20, self.accumulator.ErrorCount())

    bounded_list = self.accumulator.ProblemList(
        transitfeed.TYPE_ERROR, "OtherProblem")
    self.assertEquals(20, bounded_list.count)
    self.assertEquals(17, bounded_list.dropped_count)
    self.assertProblemsAttribute(transitfeed.TYPE_ERROR,  "OtherProblem",
        "description", "e10 e11 e12")
dataset/ETHPy150Open google/transitfeed/tests/testfeedvalidator.py/LimitPerTypeProblemReporterTestCase.testKeepUnsorted/original