Ticket #121: fix_test_banana.diff

File fix_test_banana.diff, 1.4 KB (added by ivank, 16 years ago)

call Decimal to create NaN and Inf instead of importing them

  • foolscap/test/test_banana.py

    diff --git a/foolscap/test/test_banana.py b/foolscap/test/test_banana.py
    index 513ce7a..449eb42 100644
    a b from foolscap.banana import int2b128, long_to_bytes 
    1616
    1717import StringIO
    1818import sets, struct
    19 from decimal import Decimal, Inf, NaN
     19from decimal import Decimal
    2020
    2121#log.startLogging(sys.stderr)
    2222
    class ThereAndBackAgain(TestBananaMixin, unittest.TestCase): 
    16801680        d.addCallback(lambda res: self.looptest(Decimal("-123.456")))
    16811681        d.addCallback(lambda res: self.looptest(Decimal("0.000003")))
    16821682        d.addCallback(lambda res: self.looptest(Decimal("-0.000003")))
    1683         d.addCallback(lambda res: self.looptest(Decimal(Inf)))
    1684         d.addCallback(lambda res: self.looptest(Decimal(-Inf)))
     1683        d.addCallback(lambda res: self.looptest(Decimal('Inf')))
     1684        d.addCallback(lambda res: self.looptest(Decimal('-Inf')))
    16851685        # NaN is a bit weird: by definition, NaN != NaN. So we need to make
    16861686        # sure it serializes, and that str(new) == str(old), but we don't
    16871687        # check that new == old.
    1688         d.addCallback(lambda res: self.loop(Decimal(NaN)))
     1688        d.addCallback(lambda res: self.loop(Decimal('NaN')))
    16891689        def _check_NaN(new_NaN):
    1690             self.failUnlessEqual(str(new_NaN), str(Decimal(NaN)))
     1690            self.failUnlessEqual(str(new_NaN), str(Decimal('NaN')))
    16911691        d.addCallback(_check_NaN)
    16921692        return d
    16931693