subhashb commented on code in PR #1181:
URL: https://github.com/apache/avro/pull/1181#discussion_r1265795930
##########
lang/py/avro/test/test_schema.py:
##########
@@ -634,13 +832,29 @@ def test_fixed_decimal_invalid_max_precision(self):
def test_parse_invalid_symbol(self):
"""Disabling enumschema symbol validation should allow invalid symbols
to pass."""
test_schema_string = json.dumps({"type": "enum", "name": "AVRO2174",
"symbols": ["white space"]})
- with self.assertRaises(avro.errors.InvalidName, msg="When enum symbol
validation is enabled, an invalid symbol should raise InvalidName."):
+
+ try:
avro.schema.parse(test_schema_string, validate_enum_symbols=True)
+ except avro.errors.InvalidName:
+ pass
+ else:
+ self.fail("When enum symbol validation is enabled, an invalid
symbol should raise InvalidName.")
Review Comment:
Aah, I understand better now. I am unsure about the history of this piece of
code - it has been a long time since I wrote it the first time. 🧐
I have now replaced the `try/except` with `assertRaises` for the first part
of the test and retained the second `try/except` to [check the exception was
not raised](https://stackoverflow.com/a/4319870/1858466).
##########
lang/py/avro/test/test_schema.py:
##########
@@ -634,13 +832,29 @@ def test_fixed_decimal_invalid_max_precision(self):
def test_parse_invalid_symbol(self):
"""Disabling enumschema symbol validation should allow invalid symbols
to pass."""
test_schema_string = json.dumps({"type": "enum", "name": "AVRO2174",
"symbols": ["white space"]})
- with self.assertRaises(avro.errors.InvalidName, msg="When enum symbol
validation is enabled, an invalid symbol should raise InvalidName."):
+
+ try:
avro.schema.parse(test_schema_string, validate_enum_symbols=True)
+ except avro.errors.InvalidName:
+ pass
+ else:
+ self.fail("When enum symbol validation is enabled, an invalid
symbol should raise InvalidName.")
Review Comment:
Aah, I understand better now. I am unsure about the history of this piece of
code - it has been a long time since I wrote it the first time. 🧐
I have now replaced the `try/except` with `assertRaises` for the first part
of the test and retained the second `try/except` to [check the exception was
not raised](https://stackoverflow.com/a/4319870/1858466).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]