diff options
author | Balazs Gibizer <balazs.gibizer@est.tech> | 2020-06-26 15:34:52 +0200 |
---|---|---|
committer | Balazs Gibizer <balazs.gibizer@est.tech> | 2020-06-26 15:36:51 +0200 |
commit | bc562f3393e976e7086642f03ef62a914a9b2dcc (patch) | |
tree | 0cfdc44acd24da979c1b73db5aeeb1cbef92edb4 | |
parent | b9938230f992935e8332b6e288937be890724cd2 (diff) | |
download | oslo-utils-bc562f3393e976e7086642f03ef62a914a9b2dcc.tar.gz |
Fix uuidsentinel to follow getattr protocol4.2.2
This patch changes the exception type raise by uuidsentinel when the
sentinel name starts with '_'. The __getattr__ protocol requires to
raise an AttributeError if the attribute value cannot be returned.
Closes-Bug: #1885281
Change-Id: I1076a957a19507e7d96ef429c0ae5d0ee8a90e66
-rw-r--r-- | oslo_utils/fixture.py | 2 | ||||
-rw-r--r-- | oslo_utils/tests/test_fixture.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/oslo_utils/fixture.py b/oslo_utils/fixture.py index 912d81b..6a874de 100644 --- a/oslo_utils/fixture.py +++ b/oslo_utils/fixture.py @@ -79,7 +79,7 @@ class _UUIDSentinels(object): def __getattr__(self, name): if name.startswith('_'): - raise ValueError('Sentinels must not start with _') + raise AttributeError('Sentinels must not start with _') with self._lock: if name not in self._sentinels: self._sentinels[name] = uuidutils.generate_uuid() diff --git a/oslo_utils/tests/test_fixture.py b/oslo_utils/tests/test_fixture.py index dafac2f..5775136 100644 --- a/oslo_utils/tests/test_fixture.py +++ b/oslo_utils/tests/test_fixture.py @@ -80,5 +80,5 @@ class UUIDSentinelsTest(test_base.BaseTestCase): self.assertIsInstance(uuids.foo, str) def test_with_underline_prefix(self): - ex = self.assertRaises(ValueError, getattr, uuids, '_foo') + ex = self.assertRaises(AttributeError, getattr, uuids, '_foo') self.assertIn("Sentinels must not start with _", six.text_type(ex)) |