3132count('div',1)33count('a',2)34count('em',0)35# Element names are case-insensitive in HTML36count('DIV',1)37# ... but not in XHTML or XML38count('DIV',0,translator='xhtml')39count('DIV',0,translator='xml')4041# :contains() is case-insensitive in lxml42count(':contains("link")',2)# div, a43count(':contains("LInk")',2)44# Whatever the document language45count(':contains("LInk")',2,translator='xhtml')46count(':contains("LInk")',2,translator='xml')47# ... but not in upstream cssselect48importcssselect49count(':contains("link")',2,translator=cssselect.HTMLTranslator())50count(':contains("LInk")',0,translator=cssselect.HTMLTranslator())
54suite=unittest.TestSuite()55try:56importcssselect57exceptImportError:58# no 'cssselect' installed59print("Skipping tests in lxml.cssselect - external cssselect package is not installed")60returnsuite6162importlxml.cssselect63suite.addTests(doctest.DocTestSuite(lxml.cssselect))64suite.addTests([unittest.makeSuite(CSSTestCase)])65returnsuite