예제 #1
0
    def test_iteration(self):
        nsm = NamespaceMap()
        uripat = 'http://example.com/foo%r'

        nsm.add(uripat % 0)
        for n in range(1, 23):
            self.assertIn(uripat % (n - 1), nsm)
            self.assertTrue(nsm.isDefined(uripat % (n - 1)))
            nsm.add(uripat % n)

        for (uri, alias) in nsm.iteritems():
            self.assertEqual(uri[22:], alias[3:])

        i = 0
        it = nsm.iterAliases()
        try:
            while True:
                it.next()
                i += 1
        except StopIteration:
            self.assertEqual(i, 23)

        i = 0
        it = nsm.iterNamespaceURIs()
        try:
            while True:
                it.next()
                i += 1
        except StopIteration:
            self.assertEqual(i, 23)
예제 #2
0
    def test_iteration(self):
        nsm = NamespaceMap()
        uripat = 'http://example.com/foo%r'

        nsm.add(uripat % 0)
        for n in range(1, 23):
            self.assertIn(uripat % (n - 1), nsm)
            self.assertTrue(nsm.isDefined(uripat % (n - 1)))
            nsm.add(uripat % n)

        for (uri, alias) in nsm.items():
            self.assertEqual(uri[22:], alias[3:])

        for (uri, alias) in nsm.iteritems():
            self.assertEqual(uri[22:], alias[3:])

        self.assertEqual(len(tuple(nsm.iterAliases())), 23)
        self.assertEqual(len(tuple(nsm.iterNamespaceURIs())), 23)