tests/test_functions.py
2Tests for `funkycache.functions`.
5from pathlib import Path
10def test_canonical_name_varies_by_path(tmp_path: Path) -> None:
12 The canonical name of functions in the top-level of a script
15 For these functions, func.__module__ is __main__, so we need a way
16 to distinguish them to avoid cache collisions.
18 (tmp_path / "s1.py").write_text(
20 from funkycache.functions import canonical_func_name
22 def greet(name: str) -> str:
23 return f"Hello {name}!"
25 print(canonical_func_name(greet))
29 (tmp_path / "s2.py").write_text(
31 from funkycache.functions import canonical_func_name
33 def greet(name: str) -> str:
34 return f"Hello {name}!"
36 print(canonical_func_name(greet))
40 name1 = subprocess.check_output(["python3", (tmp_path / "s1.py")])
41 name2 = subprocess.check_output(["python3", (tmp_path / "s2.py")])