diff options
author | Leonard Richardson <leonardr@segfault.org> | 2023-02-07 10:37:50 -0500 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2023-02-07 10:37:50 -0500 |
commit | 7eedde44d45f99340bcf98384dfb11295ffcebdd (patch) | |
tree | a1398bc82bb843b90631aa2941787a37e0e5ab98 /bs4/tests/test_css.py | |
parent | 6d70cafddd4a265feec5a30cc5b302fd6fbaeb83 (diff) |
Removed Soup Sieve fallback method, added documentation.
Diffstat (limited to 'bs4/tests/test_css.py')
-rw-r--r-- | bs4/tests/test_css.py | 19 |
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() |