MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / ImmutableDictTest

Class ImmutableDictTest

test/base/test_utils.py:377–598  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375
376
377class ImmutableDictTest(fixtures.TestBase):
378 methods = combinations(
379 util.immutabledict.union,
380 util.immutabledict.merge_with,
381 argnames="method",
382 )
383
384 @methods
385 def test_no_change(self, method):
386 d = util.immutabledict({1: 2, 3: 4})
387
388 d2 = method(d)
389 is_(d2, d)
390 d2 = method(d, {})
391 is_(d2, d)
392 d2 = method(d, None)
393 is_(d2, d)
394 d2 = method(d, {}, {}, {}, None)
395 is_(d2, d)
396
397 @methods
398 def test_no_change_self_empty(self, method):
399 d = util.immutabledict({1: 2, 3: 4})
400 e = util.immutabledict()
401 d2 = method(e, d)
402
403 eq_(e, {})
404 is_(d2, d)
405
406 d2 = method(e, {}, d)
407 is_(d2, d)
408 d2 = method(e, None, d, {}, {})
409 is_(d2, d)
410
411 d2 = method(e, {1: 2, 3: 4})
412
413 eq_(d2, d)
414 assert isinstance(d2, util.immutabledict)
415
416 d2 = method(e, {1: 2, 3: 4}, {3: 5, 4: 7})
417
418 eq_(d2, {1: 2, 3: 5, 4: 7})
419 assert isinstance(d2, util.immutabledict)
420
421 @methods
422 def test_start_empty_but_then_populate(self, method):
423 d = util.immutabledict()
424
425 d2 = method(d, {1: 2})
426 eq_(d2, {1: 2})
427 is_not(d2, d)
428
429 d3 = method(d, util.immutabledict(), {1: 2})
430 eq_(d3, {1: 2})
431
432 d4 = method(
433 d, util.immutabledict(), util.immutabledict({1: 2}), {3: 4}
434 )

Callers

nothing calls this directly

Calls 1

combinationsFunction · 0.90

Tested by

no test coverage detected