Coverage for tests / test_depends_hashable.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-04-06 01:24 +0000
1# This is more or less a workaround to make Depends and Security hashable
2# as other tools that use them depend on that
3# Ref: https://github.com/fastapi/fastapi/pull/14320
5from fastapi import Depends, Security 1efgh
8def dep(): 1efgh
9 pass 1abcd
12def test_depends_hashable(): 1efgh
13 dep() # just for coverage 1abcd
14 d1 = Depends(dep) 1abcd
15 d2 = Depends(dep) 1abcd
16 d3 = Depends(dep, scope="function") 1abcd
17 d4 = Depends(dep, scope="function") 1abcd
19 s1 = Security(dep) 1abcd
20 s2 = Security(dep) 1abcd
22 assert hash(d1) == hash(d2) 1abcd
23 assert hash(s1) == hash(s2) 1abcd
24 assert hash(d1) != hash(d3) 1abcd
25 assert hash(d3) == hash(d4) 1abcd