summaryrefslogtreecommitdiff
path: root/sandbox/rstdiff/studies/hashable.py
blob: 803bb867efdb3a6e8fb7009ef5e98c8e3231930a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# A study to check how a Docutils node can be made hashable

from docutils.nodes import Node

from treediff import HashableImpl

__docformat__ = 'reStructuredText'

class HashableDocutilsNodeImpl(HashableImpl):
    """Implements equality for a docutils `Node`."""

    def __init__(self):
        super(self.__class__, self).__init__(Node)

if __name__ == '__main__':
    hashableImpl = HashableDocutilsNodeImpl()
    hashableImpl.debug = True

    n1 = Node()
    n2 = Node()
    print(n1 == n1)
    print(n1 == n2)
    print(n1 != n2)
    h = { n1: 'bla' }