MCPcopy Create free account
hub / github.com/dask/dask / test_tokenize_functions_main

Function test_tokenize_functions_main

dask/tests/test_tokenize.py:1195–1238  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1193
1194
1195def test_tokenize_functions_main():
1196 script = """
1197 def inc(x):
1198 return x + 1
1199
1200 inc2 = inc
1201 def sum(x, y):
1202 return x + y
1203
1204 from dask.base import tokenize
1205 assert tokenize(inc) != tokenize(sum)
1206 # That this is an alias shouldn't matter
1207 assert tokenize(inc) == tokenize(inc2)
1208
1209 def inc(x):
1210 return x + 1
1211
1212 assert tokenize(inc2) != tokenize(inc)
1213
1214 def inc(y):
1215 return y + 1
1216
1217 assert tokenize(inc2) != tokenize(inc)
1218
1219 def inc(x):
1220 y = x
1221 return y + 1
1222
1223 assert tokenize(inc2) != tokenize(inc)
1224
1225 # Test that redefining a function changes the token
1226 def func(x):
1227 return x + 1
1228
1229 result = tokenize(func)
1230
1231 def func(x):
1232 return x + 2
1233
1234 result2 = tokenize(func)
1235 assert result != result2
1236 """
1237 proc = subprocess.run([sys.executable, "-c", textwrap.dedent(script)])
1238 proc.check_returncode()
1239
1240
1241def test_tokenize_dataclass_field_no_repr():

Callers

nothing calls this directly

Calls 1

runMethod · 0.80

Tested by

no test coverage detected