Changeset 1146

Show
Ignore:
Timestamp:
03/25/08 02:32:07 (2 years ago)
Author:
nick
Message:

Fixed failing tests ..

Location:
pyamf/trunk/pyamf
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pyamf/trunk/pyamf/amf0.py

    r1101 r1146  
    221221        @rtype: C{int} or C{float} 
    222222        """ 
    223         x = self.stream.read_double() 
    224  
    225         return _check_for_int(x) 
     223        return _check_for_int(self.stream.read_double()) 
    226224 
    227225    def readBoolean(self): 
  • pyamf/trunk/pyamf/tests/test_amf0.py

    r1101 r1146  
    499499        self.buf.seek(0) 
    500500        x = self.decoder.readElement() 
    501  
    502501        self.assertTrue(fpconst.isNaN(x)) 
    503502 
  • pyamf/trunk/pyamf/tests/test_util.py

    r1145 r1146  
    273273        util.StringIOProxy._wrapped_class = StringIO 
    274274 
    275 class ByteStream(util.StringIOProxy, util.NetworkIOMixIn): 
     275class ByteStream(util.StringIOProxy, util.DataTypeMixIn): 
    276276    pass 
    277277 
     
    415415        x = ByteStream() 
    416416 
    417         self._write_endian(x, x.write_utf8_string, (u'ᚠᛇᚻ',), ( 
    418             '\xe1\x9a\xa0\xe1\x9b\x87\xe1\x9a\xbb', '\xe1\x9a\xa0\xe1\x9b\x87\xe1\x9a\xbb')) 
     417        self._write_endian(x, x.write_utf8_string, (u'ᚠᛇᚻ',), ['\xe1\x9a\xa0\xe1\x9b\x87\xe1\x9a\xbb'] * 2) 
    419418 
    420419    def test_read_utf8_string(self): 
  • pyamf/trunk/pyamf/util.py

    r1145 r1146  
    532532import fpconst 
    533533 
    534 fp = struct.unpack("!d", '\xff\xf8\x00\x00\x00\x00\x00\x00')[0] 
    535  
    536 if not fpconst.isNaN(fp): 
    537     def read_float_workaround(self): 
     534if not fpconst.isNaN(struct.unpack("!d", '\xff\xf8\x00\x00\x00\x00\x00\x00')[0]): 
     535    def read_double_workaround(self): 
    538536        bytes = self._read(8) 
    539537 
     
    547545            return fpconst.PosInf 
    548546 
    549         return struct.unpack("!d", bytes)[0] 
    550  
    551     NetworkIOMixIn.read_double = read_float_workaround 
    552  
    553     def write_float_workaround(self, d): 
     547        return struct.unpack("%sd" % self.endian, bytes)[0] 
     548 
     549    DataTypeMixIn.read_double = read_double_workaround 
     550 
     551    def write_double_workaround(self, d): 
    554552        if fpconst.isNaN(d): 
    555553            self.write('\xff\xf8\x00\x00\x00\x00\x00\x00') 
     
    559557            self.write('\x7f\xf0\x00\x00\x00\x00\x00\x00') 
    560558        else: 
    561             write_float_workaround.old_func(self, d) 
    562  
    563     x = NetworkIOMixIn.write_double 
    564     NetworkIOMixIn.write_double = write_float_workaround 
    565     write_float_workaround.old_func = x 
    566  
    567 del fp 
     559            write_double_workaround.old_func(self, d) 
     560 
     561    x = DataTypeMixIn.write_double 
     562    DataTypeMixIn.write_double = write_double_workaround 
     563    write_double_workaround.old_func = x