Skip to content

Commit 0eab32e

Browse files
authored
Test tokenization of static and class methods (#10872)
1 parent 1b711be commit 0eab32e

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

dask/tests/test_tokenize.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,34 @@ def hello(self):
409409
assert before != after
410410

411411

412+
def test_staticmethods():
413+
class Foo:
414+
def __init__(self, x):
415+
self.x = x
416+
417+
def normal_method(self):
418+
pass
419+
420+
@staticmethod
421+
def static_method():
422+
pass
423+
424+
@classmethod
425+
def class_method(cls):
426+
pass
427+
428+
class Bar(Foo):
429+
pass
430+
431+
a, b, c = Foo(1), Foo(2), Bar(1)
432+
assert tokenize(a) != tokenize(b)
433+
assert tokenize(a.normal_method) != tokenize(b.normal_method)
434+
assert tokenize(a.static_method) == tokenize(b.static_method)
435+
assert tokenize(a.static_method) == tokenize(c.static_method)
436+
assert tokenize(a.class_method) == tokenize(b.class_method)
437+
assert tokenize(a.class_method) != tokenize(c.class_method)
438+
439+
412440
@pytest.mark.skipif("not np")
413441
def test_tokenize_sequences():
414442
assert tokenize([1]) != tokenize([2])

0 commit comments

Comments
 (0)