Fix broken test case on Python 3.8

- Simplify broken test and make it work on python 3.8
- Add python 3.8 to mandatory test cases
pull/2400/head
Åke Forslund 2019-11-28 09:02:59 +01:00
parent e6385720b3
commit 5e863515da
2 changed files with 13 additions and 5 deletions

View File

@ -16,9 +16,6 @@ python:
- "3.6"
- "3.7"
- "3.8"
jobs:
allow_failures:
- python: "3.8"
# don't rebuild pocketsphinx for every build
cache:
- pip

View File

@ -183,10 +183,21 @@ class TestNormalize(unittest.TestCase):
# invoke helper functions directly to test certain conditions which are
# difficult to trigger on purpose.
replaceable = _ReplaceableNumber(1, ["test_token"])
self.assertRaises(AttributeError, setattr(replaceable, "key", None))
# Check that built in members can't be changed
with self.assertRaises(Exception) as error:
setattr(replaceable, "key", type(None))
replaceable.value = 42
self.assertEqual(error.message, "Immutable!")
with self.assertRaises(Exception) as error:
replaceable.tokens = ["flowerpot", "whale"]
self.assertEqual(error.message, "Immutable!")
# Check that new member can be added but not modified
replaceable.key = "exist"
with self.assertRaises(Exception) as error:
replaceable.key = "exists?"
self.assertEqual(error.message, "Immutable!")
self.assertEqual(str(replaceable), "(1, ['test_token'])")
self.assertEqual(repr(replaceable),
"_ReplaceableNumber(1, ['test_token'])")