Gael Pasgrimaud avatar Gael Pasgrimaud committed 0512a85

fix #64 #66

Comments (0)

Files changed (5)

buildout-py3k.cfg

 develop = .
 
 [eggs]
-recipe = zc.recipe.egg
+recipe = z3c.recipe.script
 eggs =
     WebOb>1.1.9
     pyquery
 You can play with css classes::
 
     >>> p.addClass("toto")
-    [<p#hello.toto.hello>]
+    [<p#hello.hello.toto>]
     >>> p.toggleClass("titi toto")
     [<p#hello.titi.hello>]
     >>> p.removeClass("titi")

pyquery/pyquery.py

         """
         for tag in self:
             values = value.split(' ')
-            classes = set((tag.get('class') or '').split())
-            classes = classes.union(values)
-            classes.difference_update([''])
+            classes = (tag.get('class') or '').split()
+            classes += [v for v in values if v not in classes]
             tag.set('class', ' '.join(classes))
         return self
 
             text = []
 
             def add_text(tag, no_tail=False):
-                if tag.text:
+                if tag.text and not isinstance(tag, lxml.etree._Comment):
                     text.append(tag.text)
                 for child in tag.getchildren():
                     add_text(child)
         assert len(doc('.node')) == 1, doc
 
 
+class TestComment(unittest.TestCase):
+
+    def test_comment(self):
+        doc = pq('<div><!-- foo --> bar</div>')
+        self.assertEqual(doc.text(), 'bar')
+
+
 class TestCallback(unittest.TestCase):
     html = """
         <ol>
 basepython=python3.2
 changedir={toxinidir}
 commands =
-    rm -f .installed.cfg
-    python3.2 bootstrap-py3k.py buildout:parts-directory={envdir}/parts buildout:bin-directory={envbindir}
-    {envbindir}/buildout -c buildout-py3k.cfg buildout:parts-directory={envdir}/parts buildout:bin-directory={envbindir}
     {envbindir}/nosetests
+deps =
+  nose
+  webob
 
 [testenv:py33]
 basepython=python3.3
 changedir={toxinidir}
 commands =
-    rm -f .installed.cfg
-    python3.3 bootstrap-py3k.py buildout:parts-directory={envdir}/parts buildout:bin-directory={envbindir}
-    {envbindir}/buildout -c buildout-py3k.cfg buildout:parts-directory={envdir}/parts buildout:bin-directory={envbindir}
     {envbindir}/nosetests
+deps =
+  nose
+  webob
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.