tests: Stop trying to mutate instantiated EntryPoints
py311 made EntryPoints immutable. Subclass instead. Closes-Bug: #2009228 Change-Id: I90198b1bb6b18b752e0fdc4d4d920914ea449413
This commit is contained in:
@@ -3840,22 +3840,25 @@ cluster_dfw1 = http://dfw1.host/v1/
|
|||||||
@mock.patch('importlib.metadata.distribution')
|
@mock.patch('importlib.metadata.distribution')
|
||||||
def test_load_pkg_resource_importlib(self, mock_driver):
|
def test_load_pkg_resource_importlib(self, mock_driver):
|
||||||
import importlib.metadata
|
import importlib.metadata
|
||||||
|
|
||||||
|
class TestEntryPoint(importlib.metadata.EntryPoint):
|
||||||
|
def load(self):
|
||||||
|
return self.value
|
||||||
|
|
||||||
repl_obj = object()
|
repl_obj = object()
|
||||||
ec_obj = object()
|
ec_obj = object()
|
||||||
other_obj = object()
|
other_obj = object()
|
||||||
mock_driver.return_value.entry_points = [
|
mock_driver.return_value.entry_points = [
|
||||||
importlib.metadata.EntryPoint(group='swift.diskfile',
|
TestEntryPoint(group='swift.diskfile',
|
||||||
name='replication.fs',
|
name='replication.fs',
|
||||||
value=repl_obj),
|
value=repl_obj),
|
||||||
importlib.metadata.EntryPoint(group='swift.diskfile',
|
TestEntryPoint(group='swift.diskfile',
|
||||||
name='erasure_coding.fs',
|
name='erasure_coding.fs',
|
||||||
value=ec_obj),
|
value=ec_obj),
|
||||||
importlib.metadata.EntryPoint(group='swift.section',
|
TestEntryPoint(group='swift.section',
|
||||||
name='thing.other',
|
name='thing.other',
|
||||||
value=other_obj),
|
value=other_obj),
|
||||||
]
|
]
|
||||||
for ep in mock_driver.return_value.entry_points:
|
|
||||||
ep.load = lambda ep=ep: ep.value
|
|
||||||
tests = {
|
tests = {
|
||||||
('swift.diskfile', 'egg:swift#replication.fs'): repl_obj,
|
('swift.diskfile', 'egg:swift#replication.fs'): repl_obj,
|
||||||
('swift.diskfile', 'egg:swift#erasure_coding.fs'): ec_obj,
|
('swift.diskfile', 'egg:swift#erasure_coding.fs'): ec_obj,
|
||||||
|
|||||||
Reference in New Issue
Block a user