1from nevow import tags, flat, context
2from nevow.testutil import TestCase
3
4class TestTags(TestCase):
5    def test_directiveComparison(self):
6        """
7        Test that only directives with the same name compare equal.
8        """
9        foo = tags.directive('foo')
10        foo2 = tags.directive('foo')
11        bar = tags.directive('bar')
12        self.assertEquals(foo, foo)
13        self.assertEquals(foo, foo2)
14        self.failIfEqual(foo, bar)
15
16
17    def test_directiveHashing(self):
18        """
19        Test that only directives with the same name hash to the same thing.
20        """
21        foo = tags.directive('foo')
22        foo2 = tags.directive('foo')
23        bar = tags.directive('bar')
24        self.assertEquals(hash(foo), hash(foo2))
25
26        # XXX What if 'foo' and 'bar' accidentally hash equal in some version
27        # of Python?
28        self.failIfEqual(hash(foo), hash(bar))
29