diff options
author | Federico Caselli <cfederico87@gmail.com> | 2022-10-21 21:11:23 +0200 |
---|---|---|
committer | Federico Caselli <cfederico87@gmail.com> | 2022-10-22 09:55:49 +0200 |
commit | 25619f27836e80351e078c8badc47b3e0acccf5d (patch) | |
tree | f9001942299288f1c6dfbd7d2179b15514330a5b /test/base/test_utils.py | |
parent | bbf68345f4993245689b96cc6c6a50013afa3caa (diff) | |
download | sqlalchemy-25619f27836e80351e078c8badc47b3e0acccf5d.tar.gz |
Add pep 584 to python immutabledict fallback
Fixes: #8695
Change-Id: Ie0412c3a7b2b1ba5bd5112f204318ff763cbb8f4
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r-- | test/base/test_utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index 27945f236..0ef86545b 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -343,6 +343,23 @@ class ImmutableDictTest(fixtures.TestBase): i2 = util.immutabledict({"a": 42, 42: "a"}) eq_(str(i2), "immutabledict({'a': 42, 42: 'a'})") + @testing.requires.python39 + def test_pep584(self): + i = util.immutabledict({"a": 2}) + with expect_raises_message(TypeError, "object is immutable"): + i |= {"b": 42} + eq_(i, {"a": 2}) + + i2 = i | {"x": 3} + eq_(i, {"a": 2}) + eq_(i2, {"a": 2, "x": 3}) + is_true(isinstance(i2, util.immutabledict)) + + i2 = {"x": 3} | i2 + eq_(i, {"a": 2}) + eq_(i2, {"a": 2, "x": 3}) + is_true(isinstance(i2, util.immutabledict)) + class ImmutableTest(fixtures.TestBase): @combinations(util.immutabledict({1: 2, 3: 4}), util.FacadeDict({2: 3})) |