Skip to content

Commit

Permalink
Added a unit test to make sure each <article> has tab-pane and active
Browse files Browse the repository at this point in the history
  • Loading branch information
Denubis authored and fmichonneau committed Mar 16, 2019
1 parent e732111 commit 08894f5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ before_script:
- "python bin/_travis.py"
script:
- python bin/workshop_check.py .
- python -m unittest bin/_test/bs4test.py
branches:
only:
- gh-pages
31 changes: 31 additions & 0 deletions bin/_test/bs4test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import unittest
from bs4 import BeautifulSoup
import os
from pathlib import Path
from git_root import git_root

class beautifulSoupTests(unittest.TestCase):
"""
This test sets up a bs4 (https://www.crummy.com/software/BeautifulSoup/bs4/doc/#installing-beautiful-soup)
runner for tests of index.md that do not require a web browser.
"""

#https://github.com/jtilly/git_root
soup = BeautifulSoup("", 'html.parser')
def setUp(self):
with open(Path(git_root()) / 'index.md', "r") as index:
indexpage = index.read()
self.soup = BeautifulSoup(indexpage , 'html.parser')

def test_for_active_css_in_tabs(self):
"""
As per https://github.com/carpentries/workshop-template/pull/573/files
all tab divs need to have the active class in index.md
"""
for article in self.soup.find_all("article"):
self.assertIn('active', article['class'])
self.assertIn('tab-pane', article['class'])


if __name__ == '__main__':
unittest.main()
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
PyYAML
beautifulsoup4
git_root

0 comments on commit 08894f5

Please sign in to comment.