Skip to content

Commit d0bcd42

Browse files
committed
Tests: SR error messages have changed; change matchers
1 parent 5bd43b6 commit d0bcd42

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

tests/integration/consumer/test_consumer_error.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#
1818

1919
import pytest
20-
from confluent_kafka.cimpl import TopicPartition, OFFSET_END
20+
from confluent_kafka import TopicPartition, OFFSET_END, KafkaError
2121

2222
from confluent_kafka.error import ConsumeError
2323
from confluent_kafka.serialization import StringSerializer
@@ -39,6 +39,8 @@ def test_consume_error(kafka_cluster):
3939
value_deserializer=StringSerializer())
4040
consumer.assign([TopicPartition(topic, 0, OFFSET_END)])
4141

42-
with pytest.raises(ConsumeError, match="No more messages"):
42+
with pytest.raises(ConsumeError) as exc_info:
4343
# Trigger EOF error
4444
consumer.poll()
45+
assert exc_info.value.args[0].code() == KafkaError._PARTITION_EOF, \
46+
"Expected _PARTITION_EOF, not {}".format(exc_info)

tests/integration/schema_registry/test_api_client.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ def test_api_register_schema_invalid(kafka_cluster, load_file):
8686
schema = Schema(load_file('invalid_schema.avsc'), schema_type='AVRO')
8787
subject = _subject_name('test_invalid_schema')
8888

89-
with pytest.raises(SchemaRegistryError, match="Input schema is an invalid"
90-
" Avro schema") as e:
89+
with pytest.raises(SchemaRegistryError) as e:
9190
sr.register_schema(subject, schema)
9291
assert e.value.http_status_code == 422
9392
assert e.value.error_code == 42201
@@ -126,7 +125,7 @@ def test_api_get_schema_not_found(kafka_cluster, load_file):
126125
"""
127126
sr = kafka_cluster.schema_registry()
128127

129-
with pytest.raises(SchemaRegistryError, match="Schema not found") as e:
128+
with pytest.raises(SchemaRegistryError, match="Schema .*not found.*") as e:
130129
sr.get_schema(999999)
131130

132131
assert e.value.http_status_code == 404
@@ -148,7 +147,7 @@ def test_api_get_registration_subject_not_found(kafka_cluster, load_file):
148147

149148
subject = _subject_name("registration_subject_not_found")
150149

151-
with pytest.raises(SchemaRegistryError, match="Subject not found") as e:
150+
with pytest.raises(SchemaRegistryError, match="Subject .*not found.*") as e:
152151
sr.lookup_schema(subject, schema)
153152
assert e.value.http_status_code == 404
154153
assert e.value.error_code == 40401
@@ -265,7 +264,7 @@ def test_api_delete_subject_not_found(kafka_cluster):
265264

266265
subject = _subject_name("test-delete_invalid_subject")
267266

268-
with pytest.raises(SchemaRegistryError, match="Subject not found") as e:
267+
with pytest.raises(SchemaRegistryError, match="Subject .*not found.*") as e:
269268
sr.delete_subject(subject)
270269
assert e.value.http_status_code == 404
271270
assert e.value.error_code == 40401
@@ -302,7 +301,7 @@ def test_api_get_subject_version_no_version(kafka_cluster, load_file):
302301
subject = _subject_name('test-get_subject')
303302
sr.register_schema(subject, schema)
304303

305-
with pytest.raises(SchemaRegistryError, match="Version not found") as e:
304+
with pytest.raises(SchemaRegistryError, match="Version .*not found") as e:
306305
sr.get_version(subject, version=3)
307306
assert e.value.http_status_code == 404
308307
assert e.value.error_code == 40402
@@ -316,8 +315,9 @@ def test_api_get_subject_version_invalid(kafka_cluster, load_file):
316315
subject = _subject_name('test-get_subject')
317316
sr.register_schema(subject, schema)
318317

319-
with pytest.raises(SchemaRegistryError, match="The specified version is not"
320-
" a valid version id") as e:
318+
with pytest.raises(SchemaRegistryError,
319+
match="The specified version .*is not"
320+
" a valid version id.*") as e:
321321
sr.get_version(subject, version='a')
322322
assert e.value.http_status_code == 422
323323
assert e.value.error_code == 42202

tests/test_error.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# limit
1717
#
1818

19-
from confluent_kafka.cimpl import KafkaError
19+
from confluent_kafka import KafkaError
2020
from confluent_kafka.error import ConsumeError, \
2121
ProduceError
2222

0 commit comments

Comments
 (0)