Created
January 7, 2021 11:50
-
-
Save morlandi/898f355b70a2845d2dd66e4bc686ff71 to your computer and use it in GitHub Desktop.
Parsing HTML in a Django unit test with BeatifulSoap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
def check_diary_table_disabled(self, response): | |
""" | |
Parse #diary-table from HTML, and check for 'disabled' class | |
""" | |
html = BeautifulSoup(response.content, features="lxml") | |
diary_table = html.find('table', {'id': 'diary-table', }, recursive=True) | |
diary_table_attrs = diary_table.attrs | |
self.assertIn('class', diary_table_attrs) | |
disabled = 'disabled' in diary_table_attrs['class'] | |
return disabled |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment