-
-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,42 @@ | ||
"""PRAW Test Suite.""" | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class PrawTest(ABC): | ||
"""A class representing the root of all test cases""" | ||
|
||
def __init__(self): | ||
self._testcases = [] | ||
for attr in dir(self): | ||
if attr[0:4] == "test": | ||
self._testcases.append(getattr(self, attr)) | ||
|
||
def __repr__(self, name="Test Case"): | ||
return "PRAW {name} [{test_number} test cases]".format( | ||
name=self.__class__.__name__, test_number=len(self._testcases) | ||
) | ||
|
||
def __str__(self): | ||
return str(self._testcases) | ||
|
||
def __call__(self): | ||
return self.run_all_testcases() | ||
|
||
def __iter__(self): | ||
return self | ||
|
||
def __next__(self): | ||
for item in self._testcases: | ||
yield item | ||
|
||
def run_all_testcases(self): | ||
for item in dir(self): | ||
if item[0:4] == "test": | ||
case = getattr(self, item) | ||
case() | ||
|
||
@abstractmethod | ||
def setup(self): | ||
raise NotImplementedError( | ||
"Make sure to run setup before starting tests." | ||
) |
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
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