avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ham...@apache.org
Subject svn commit: r942026 - /hadoop/avro/trunk/lang/py/test/test_io.py
Date Fri, 07 May 2010 08:09:29 GMT
Author: hammer
Date: Fri May  7 08:09:28 2010
New Revision: 942026

URL: http://svn.apache.org/viewvc?rev=942026&view=rev
Log:
Follow-on commit for AVRO-526 to fix the Python tests, too. (hammer)


Modified:
    hadoop/avro/trunk/lang/py/test/test_io.py

Modified: hadoop/avro/trunk/lang/py/test/test_io.py
URL: http://svn.apache.org/viewvc/hadoop/avro/trunk/lang/py/test/test_io.py?rev=942026&r1=942025&r2=942026&view=diff
==============================================================================
--- hadoop/avro/trunk/lang/py/test/test_io.py (original)
+++ hadoop/avro/trunk/lang/py/test/test_io.py Fri May  7 08:09:28 2010
@@ -14,7 +14,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 import unittest
-import cStringIO
+try:
+  from cStringIO import StringIO
+except ImportError:
+  from StringIO import StringIO
 from binascii import hexlify
 from avro import schema
 from avro import io
@@ -110,14 +113,14 @@ def print_test_name(test_name):
   print ''
 
 def write_datum(datum, writers_schema):
-  writer = cStringIO.StringIO()
+  writer = StringIO()
   encoder = io.BinaryEncoder(writer)
   datum_writer = io.DatumWriter(writers_schema)
   datum_writer.write(datum, encoder)
   return writer, encoder, datum_writer
 
 def read_datum(buffer, writers_schema, readers_schema=None):
-  reader = cStringIO.StringIO(buffer.getvalue())
+  reader = StringIO(buffer.getvalue())
   decoder = io.BinaryDecoder(reader)
   datum_reader = io.DatumReader(writers_schema, readers_schema)
   return datum_reader.read(decoder)
@@ -152,7 +155,7 @@ def check_skip_number(number_type):
     datum_writer.write(VALUE_TO_READ, encoder)
 
     # skip the value
-    reader = cStringIO.StringIO(writer.getvalue())
+    reader = StringIO(writer.getvalue())
     decoder = io.BinaryDecoder(reader)
     decoder.skip_long()
 
@@ -250,7 +253,7 @@ class TestIO(unittest.TestCase):
        "symbols": ["BAR", "BAZ"]}""")
 
     writer, encoder, datum_writer = write_datum(datum_to_write, writers_schema)
-    reader = cStringIO.StringIO(writer.getvalue())
+    reader = StringIO(writer.getvalue())
     decoder = io.BinaryDecoder(reader)
     datum_reader = io.DatumReader(writers_schema, readers_schema)
     self.assertRaises(io.SchemaResolutionException, datum_reader.read, decoder)
@@ -284,7 +287,7 @@ class TestIO(unittest.TestCase):
        "fields": [{"name": "H", "type": "int"}]}""")
 
     writer, encoder, datum_writer = write_datum(datum_to_write, writers_schema)
-    reader = cStringIO.StringIO(writer.getvalue())
+    reader = StringIO(writer.getvalue())
     decoder = io.BinaryDecoder(reader)
     datum_reader = io.DatumReader(writers_schema, readers_schema)
     self.assertRaises(io.SchemaResolutionException, datum_reader.read, decoder)



Mime
View raw message