summaryrefslogtreecommitdiff
path: root/bs4
diff options
context:
space:
mode:
Diffstat (limited to 'bs4')
-rw-r--r--bs4/element.py11
-rw-r--r--bs4/tests/test_tree.py2
2 files changed, 8 insertions, 5 deletions
diff --git a/bs4/element.py b/bs4/element.py
index 1f121f4..f6864f2 100644
--- a/bs4/element.py
+++ b/bs4/element.py
@@ -1392,10 +1392,13 @@ class Tag(PageElement):
def recursiveChildGenerator(self):
return self.descendants
- # This was kind of misleading because has_key() (attributes) was
- # different from __in__ (contents). has_key() is gone in Python 3,
- # anyway.
- has_key = has_attr
+ def has_key(self, key):
+ """This was kind of misleading because has_key() (attributes)
+ was different from __in__ (contents). has_key() is gone in
+ Python 3, anyway."""
+ warnings.warn('has_key is deprecated. Use has_attr("%s") instead.' % (
+ key))
+ return self.has_attr(key)
# Next, a couple classes to represent queries and their results.
class SoupStrainer(object):
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py
index b07de8c..f60485b 100644
--- a/bs4/tests/test_tree.py
+++ b/bs4/tests/test_tree.py
@@ -1618,7 +1618,7 @@ class TestSoupSelector(TreeTest):
for el in els:
self.assertEqual(el.name, 'p')
self.assertEqual(els[1]['class'], ['onep'])
- self.assertFalse(els[0].has_key('class'))
+ self.assertFalse(els[0].has_attr('class'))
def test_a_bunch_of_emptys(self):
for selector in ('div#main del', 'div#main div.oops', 'div div#main'):