1
2
3 """
4 Tests for the ElementPath implementation.
5 """
6
7 from __future__ import absolute_import
8
9 import unittest
10 from .common_imports import etree, HelperTestCase
11
12
14 etree = etree
15 from lxml import _elementpath
16
18 self._elementpath._cache.clear()
19 el = self.etree.XML(b'<a><b><c/><c/></b></a>')
20 self.assertFalse(self._elementpath._cache)
21
22 self.assertTrue(el.findall('b/c'))
23 self.assertEqual(1, len(self._elementpath._cache))
24 self.assertTrue(el.findall('b/c'))
25 self.assertEqual(1, len(self._elementpath._cache))
26 self.assertFalse(el.findall('xxx'))
27 self.assertEqual(2, len(self._elementpath._cache))
28 self.assertFalse(el.findall('xxx'))
29 self.assertEqual(2, len(self._elementpath._cache))
30 self.assertTrue(el.findall('b/c'))
31 self.assertEqual(2, len(self._elementpath._cache))
32
33
34
35
36
37
38
44
45
46 if __name__ == '__main__':
47 print('to test use test.py %s' % __file__)
48