def test_remove(self): trie = NsTrie(( 'com.example.foo', 'com.example.bar' )) trie.remove('com.example') self.assertDictEqual({'com': 'com'}, trie.to_dict()) self.assertSetEqual(set(('com',)), trie.child_nodes) self.assertEqual(1, len(trie)) with self.assertRaises(KeyError): trie.remove('org.example.foo')