Update writer.py
* Update writer.py
* Update test_fastavro.py
* Update test_fastavro.py
* Update test_fastavro.py
removing try/except
MODIFY
fastavro/writer.py
fastavro/writer.py
@@ -242,7 +242,7 @@ def validate(datum, schema):
if record_type == 'long':
return (
(isinstance(datum, (int, long,)) and
- INT_MIN_VALUE <= datum <= INT_MAX_VALUE) or
+ LONG_MIN_VALUE <= datum <= LONG_MAX_VALUE) or
isinstance(datum, (datetime.time, datetime.datetime))
)

MODIFY
tests/test_fastavro.py
tests/test_fastavro.py
@@ -773,3 +773,24 @@ def test_is_avro_fo():
assert fastavro.is_avro(fp)
with open(__file__, 'rb') as fp:
assert not fastavro.is_avro(fp)
+
+
+def test_write_long_union_type():
+ schema = {
+ 'name': 'test_name',
+ 'namespace': 'test',
+ 'type': 'record',
+ 'fields': [
+ {'name': 'time', 'type': ['null', 'long']},
+ ],
+ }
+
+ new_file = MemoryIO()
+ records = [
+ {u'time': 809066167221092352},
+ ]
+ fastavro.writer(new_file, schema, records)
+ new_file.seek(0)
+ new_reader = fastavro.reader(new_file)
+ new_records = list(new_reader)
+ assert new_records == [{u'time': 809066167221092352}]

Update writer.py (#91)

* Update writer.py

* Update test_fastavro.py

* Update test_fastavro.py

* Update test_fastavro.py

removing try/except