Changeset 1666

Show
Ignore:
Timestamp:
09/10/08 22:20:14 (2 months ago)
Author:
nick
Message:

Added a way to implementation independantly check the bytestring

Location:
pyamf/branches/impl-indep-test-suite-343/pyamf/tests
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pyamf/branches/impl-indep-test-suite-343/pyamf/tests/test_amf3.py

    r1662 r1666  
    418418 
    419419        self._run([ 
    420             ({'a': u'a', 'b': u'b', 'c': u'c', 'd': u'd'}, 
    421                 '\n\x0b\x01\x03a\x06\x00\x03c\x06\x02\x03b\x06\x04\x03d\x06\x06\x01')]) 
     420            ({'a': u'a', 'b': u'b', 'c': u'c', 'd': u'd'}, ( 
     421                '\n\x0b\x01\x03', ( 
     422                    'a\x06\x00\x03', 
     423                    'c\x06\x02\x03', 
     424                    'b\x06\x04\x03',  
     425                    'd\x06\x06\x01' 
     426                )) 
     427            )]) 
    422428 
    423429        x = amf3.Decoder('\n\x0b\x01\x03a\x06\x00\x03c\x06\x02\x03b\x06\x04\x03d\x06\x06\x01') 
  • pyamf/branches/impl-indep-test-suite-343/pyamf/tests/util.py

    r1524 r1666  
    6565            self.encoder.writeElement(n) 
    6666 
    67             testcase.assertEqual(self.getval(), s) 
     67            if isinstance(s, basestring): 
     68                testcase.assertEqual(self.getval(), s) 
     69            elif isinstance(s, (tuple, list)): 
     70                testcase.assertTrue(check_buffer(self.getval(), s)) 
    6871 
    6972class DecoderTester(object): 
     
    118121        return val == float('-inf') 
    119122 
     123def check_buffer(buf, parts): 
     124    assert isinstance(parts, (tuple, list)) 
     125 
     126    for part in parts: 
     127        print repr(part) 
     128        if isinstance(part, basestring): 
     129            if buf[0:len(part)] == part: 
     130                buf = buf[len(part):] 
     131        elif isinstance(part, (tuple, list)): 
     132            if check_buffer(buf, part): 
     133                for p in part: 
     134                    buf = buf[len(part):] 
     135 
     136    return len(buf) == 0 
    120137 
    121138def replace_dict(src, dest):