Skip to content

Commit 41c0995

Browse files
sebastianneubauerRyan P
authored andcommitted
bugfix: wrong invocation of SchemaParseException (confluentinc#376)
1 parent f88c550 commit 41c0995

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

confluent_kafka/avro/load.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def loads(schema_str):
2727
return schema.parse(schema_str)
2828
else:
2929
return schema.Parse(schema_str)
30-
except schema.AvroException.SchemaParseException as e:
30+
except schema.SchemaParseException as e:
3131
raise ClientError("Schema parse failed: %s" % (str(e)))
3232

3333

setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22

3+
import os
34
from setuptools import setup, find_packages
45
from distutils.core import Extension
56
import sys
@@ -14,6 +15,16 @@
1415
'confluent_kafka/src/Producer.c',
1516
'confluent_kafka/src/Consumer.c'])
1617

18+
19+
def get_install_requirements(path):
20+
content = open(os.path.join(os.path.dirname(__file__), path)).read()
21+
return [
22+
req
23+
for req in content.split("\n")
24+
if req != '' and not req.startswith('#')
25+
]
26+
27+
1728
setup(name='confluent-kafka',
1829
version='0.11.4',
1930
description='Confluent\'s Apache Kafka client for Python',
@@ -24,5 +35,6 @@
2435
packages=find_packages(exclude=("tests", "tests.*")),
2536
data_files=[('', ['LICENSE.txt'])],
2637
extras_require={
27-
'avro': ['fastavro', 'requests', avro]
38+
'avro': ['fastavro', 'requests', avro],
39+
'dev': get_install_requirements("test-requirements.txt")
2840
})

test-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest
2+
flake8

tests/avro/invalid_scema.avsc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"type" : "record",
3+
"name" : "string_key",
4+
"namespace" : "OrbitDbProducer",
5+
"fields" : [ {
6+
"name" : "key",
7+
"type" : "array",
8+
"items": "string"
9+
} ]
10+
}

tests/avro/test_util.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#
2222

2323
import unittest
24-
24+
import pytest
2525
from avro import schema
2626
from tests.avro import data_gen
2727
from confluent_kafka import avro
@@ -35,3 +35,8 @@ def test_schema_from_string(self):
3535
def test_schema_from_file(self):
3636
parsed = avro.load(data_gen.get_schema_path('adv_schema.avsc'))
3737
self.assertTrue(isinstance(parsed, schema.Schema))
38+
39+
def test_schema_load_parse_error(self):
40+
with pytest.raises(avro.ClientError) as excinfo:
41+
avro.load(data_gen.get_schema_path("invalid_scema.avsc"))
42+
assert 'Schema parse failed:' in str(excinfo.value)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy