Coverage for tests / test_depends_hashable.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +0000
« prev ^ index » next coverage.py v7.13.3, created at 2026-02-12 18:15 +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 1defg
8def dep(): 1defg
9 pass 1abc
12def test_depends_hashable(): 1defg
13 dep() # just for coverage 1abc
14 d1 = Depends(dep) 1abc
15 d2 = Depends(dep) 1abc
16 d3 = Depends(dep, scope="function") 1abc
17 d4 = Depends(dep, scope="function") 1abc
19 s1 = Security(dep) 1abc
20 s2 = Security(dep) 1abc
22 assert hash(d1) == hash(d2) 1abc
23 assert hash(s1) == hash(s2) 1abc
24 assert hash(d1) != hash(d3) 1abc
25 assert hash(d3) == hash(d4) 1abc