From 7eedde44d45f99340bcf98384dfb11295ffcebdd Mon Sep 17 00:00:00 2001 From: Leonard Richardson Date: Tue, 7 Feb 2023 10:37:50 -0500 Subject: Removed Soup Sieve fallback method, added documentation. --- bs4/tests/test_css.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'bs4/tests/test_css.py') 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() -- cgit v1.2.3