Fix FakeSwiftCall partial env copy for None values

None values in the request environ should be copied, not replaced with
the dummy value.

Related-Change: I332ce724aa10287800cbec8ca21aacc3bbd3c22a
Change-Id: Id78ac1cac833f9284946cd364b3f95341afcb235
This commit is contained in:
Alistair Coles
2025-03-07 12:49:51 +00:00
parent 59611253f9
commit 0cdd3915c4
2 changed files with 7 additions and 3 deletions

View File

@@ -78,7 +78,9 @@ class FakeSwiftCall(object):
# mutable values. However, some things (e.g. EncInputWrapper) won't # mutable values. However, some things (e.g. EncInputWrapper) won't
# deepcopy. To avoid a confusing mixed of copied and original # deepcopy. To avoid a confusing mixed of copied and original
# values, replace un-copied values with DUMMY_VALUE. # values, replace un-copied values with DUMMY_VALUE.
if isinstance(value, (bool, int, float, str, bytes)): if value is None:
return value
elif isinstance(value, (bool, int, float, str, bytes)):
return value return value
elif isinstance(value, (list, tuple, set)): elif isinstance(value, (list, tuple, set)):
return value.__class__([self._partial_copy(v) for v in value]) return value.__class__([self._partial_copy(v) for v in value])

View File

@@ -54,7 +54,8 @@ class TestFakeSwiftCall(unittest.TestCase):
'gen4': range(4), 'gen4': range(4),
'l': a_list 'l': a_list
}, },
'z': d_dict 'z': d_dict,
'null': None,
}, },
} }
call = FakeSwiftCall(req) call = FakeSwiftCall(req)
@@ -80,7 +81,8 @@ class TestFakeSwiftCall(unittest.TestCase):
'gen4': FakeSwiftCall.DUMMY_VALUE, 'gen4': FakeSwiftCall.DUMMY_VALUE,
'l': [(1, 2), {10, FakeSwiftCall.DUMMY_VALUE}] 'l': [(1, 2), {10, FakeSwiftCall.DUMMY_VALUE}]
}, },
'z': {'a': 'b'} 'z': {'a': 'b'},
'null': None,
}, },
}, },
call.env['deep.mutable']) call.env['deep.mutable'])