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