MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_deduping_hash_algo

Method test_deduping_hash_algo

test/sql/test_compiler.py:2697–2728  ·  view source on GitHub ↗

related to #7153. testing new feature "add_hash" of _anon_label which adds an additional integer value as part of what the anon label is deduplicated upon.

(self)

Source from the content-addressed store, hash-verified

2695 )
2696
2697 def test_deduping_hash_algo(self):
2698 """related to #7153.
2699
2700 testing new feature "add_hash" of _anon_label which adds an additional
2701 integer value as part of what the anon label is deduplicated upon.
2702
2703 """
2704
2705 class Thing(ColumnElement):
2706 def __init__(self, hash_):
2707 self._hash = hash_
2708
2709 def __hash__(self):
2710 return self._hash
2711
2712 t1 = Thing(10)
2713 t2 = Thing(11)
2714
2715 # this is the collision case. therefore we assert that this
2716 # add_hash has to be below 16 bits.
2717 # eq_(
2718 # t1._anon_label('hi', add_hash=65537),
2719 # t2._anon_label('hi', add_hash=1)
2720 # )
2721 with expect_raises(AssertionError):
2722 t1._anon_label("hi", add_hash=65536)
2723
2724 for i in range(50):
2725 ne_(
2726 t1._anon_label("hi", add_hash=i),
2727 t2._anon_label("hi", add_hash=1),
2728 )
2729
2730 def test_deduping_unique_across_selects(self):
2731 """related to #7153

Callers

nothing calls this directly

Calls 4

expect_raisesFunction · 0.90
ne_Function · 0.90
_anon_labelMethod · 0.80
ThingClass · 0.70

Tested by

no test coverage detected