summaryrefslogtreecommitdiff
path: root/bs4/tests/test_css.py
diff options
context:
space:
mode:
Diffstat (limited to 'bs4/tests/test_css.py')
-rw-r--r--bs4/tests/test_css.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/bs4/tests/test_css.py b/bs4/tests/test_css.py
index a6c17de..cf73831 100644
--- a/bs4/tests/test_css.py
+++ b/bs4/tests/test_css.py
@@ -474,25 +474,20 @@ class TestCSSSelectors(SoupTest):
assert m(".foo#bar") == '\\.foo\\#bar'
assert m("()[]{}") == '\\(\\)\\[\\]\\{\\}'
assert m(".foo") == self.soup.css.escape(".foo")
-
- def test_fallback(self):
+
+ def test_api_replacement(self):
+ # You can pass in another object to act as a drop-in
+ # replacement for the soupsieve module.
class Mock():
attribute = "value"
pass
mock_soupsieve = Mock()
- mock_soupsieve.some_other_method = MagicMock()
+ mock_soupsieve.escape = MagicMock()
# If an unknown method turns out to be present in Soup Sieve,
# we may still be able to call it.
css = CSS(self.soup, api=mock_soupsieve)
- css.some_other_method("selector", 1, flags=0)
- mock_soupsieve.some_other_method.assert_called_with(
+ css.escape("identifier")
+ mock_soupsieve.escape.assert_called_with(
"selector", self.soup, 1, flags=0
)
-
- # If the attribute is not callable, getattr is a passthrough.
- assert mock_soupsieve.attribute == "value"
-
- # If the method just isn't there, too bad.
- with pytest.raises(AttributeError):
- mock_soupsieve.no_such_method()