1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
theorangeone.net-legacy/tests/TestWrapper.py

34 lines
845 B
Python
Raw Normal View History

2016-09-11 21:26:30 +01:00
import unittest
import os.path
from bs4 import BeautifulSoup
class TestClient:
output_path = os.path.realpath('./output')
def get(self, path):
file_path = self.build_path(path)
content = "".join(open(file_path).readlines())
if path.endswith('html'):
content = BeautifulSoup(content, 'html.parser')
return content
def build_path(self, path):
if path.startswith('/'):
path = path[1:]
return os.path.join(self.output_path, path)
def exists(self, path):
try:
open(self.build_path(path)).close()
return True
except FileNotFoundError:
return False
class TestCase(unittest.TestCase):
client = TestClient()
def assertTitle(self, content, title):
self.assertIn(title, content.title.string)