diff options
author | Leonard Richardson <leonardr@segfault.org> | 2021-10-24 13:26:39 -0400 |
---|---|---|
committer | Leonard Richardson <leonardr@segfault.org> | 2021-10-24 13:26:39 -0400 |
commit | dd8aa7237b88569c99e85b300b0cf537aeaebfbd (patch) | |
tree | a6923b9558dab70df4de12ccbef0e0612ad909a6 /bs4/tests/test_tree.py | |
parent | f7ec284182f3e78974fcdc7b62c88a5c3a6dbbbd (diff) |
Used a warning to formally deprecate the 'text' argument in favor of 'string'.
Diffstat (limited to 'bs4/tests/test_tree.py')
-rw-r--r-- | bs4/tests/test_tree.py | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/bs4/tests/test_tree.py b/bs4/tests/test_tree.py index 9d3ac4a..bfd6826 100644 --- a/bs4/tests/test_tree.py +++ b/bs4/tests/test_tree.py @@ -76,9 +76,7 @@ class TestFindAll(SoupTest): # Exact match. assert soup.find_all(string="bar") == ["bar"] - # 'text' is a deprecated alias for 'string'. - assert soup.find_all(text="bar") == ["bar"] - + # Match any of a number of strings. assert soup.find_all(string=["Foo", "bar"]) == ["Foo", "bar"] # Match a regular expression. @@ -1271,3 +1269,22 @@ class TestTreeModification(SoupTest): soup.a.string = cdata assert isinstance(soup.a.string, CData) + +class TestDeprecatedArguments(SoupTest): + + def test_find_type_method_string(self): + soup = self.soup("<a>some</a><b>markup</b>") + with warnings.catch_warnings(record=True) as w: + [result] = soup.find_all(text='markup') + assert result == 'markup' + assert result.parent.name == 'b' + msg = str(w[0].message) + assert msg == "The 'text' argument to find()-type methods is deprecated. Use 'string' instead." + + def test_soupstrainer_constructor_string(self): + with warnings.catch_warnings(record=True) as w: + strainer = SoupStrainer(text="text") + assert strainer.text == 'text' + msg = str(w[0].message) + assert msg == "The 'text' argument to the SoupStrainer constructor is deprecated. Use 'string' instead." + |