generated from KOLANICH/python_project_boilerplate.py
Python implementation of fileTestSuite spec
- Python 100%
| .ci | ||
| .github | ||
| fileTestSuite | ||
| tests | ||
| .editorconfig | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .gitmodules | ||
| Code_Of_Conduct.md | ||
| logo.svg | ||
| MANIFEST.in | ||
| pyproject.toml | ||
| ReadMe.md | ||
| UNLICENSE | ||
fileTestSuite.py
An implementation of fileTestSuite spec for Python.
Authoring
fileTestSuiteTool --help
init
Creates a boilerplate of meta.json.
convert
- Create a
meta.jsonin a dir. fileTestSuiteTool convert meta.jsonto convert into the binary representationfileTestSuiteTool convert meta.ftsmetato convert the binary representation back into JSON.
Testing
Via withFTS decorator
- Download a suite of test files. It can be a
git submodule.
from fileTestSuite.unittest import withFTS
- Get path of the directory of the test suite:
thisDir = Path(__file__).resolve().absolute().parent
thisDir = thisDir / "testDataset"
- Create a test
class Tests(unittest.TestCase):
@withFTS(thisDir / "testDataset") # the decorator, that must be within a `TestCase`
def testProcessorImpl(self, challFile: Path, respFile: Path, paramsDict: typing.Optional[dict]=None) -> None: # the signature must be this one!
self._testChallengeResponsePair(challFile=challFile.read_bytes(), respFile=respFile.read_bytes(), paramsDict=paramsDict) # your function
Pros:
- each file corresponds to a test
- it nicely interoperates with
pytest
Cons:
- tests are loaded at class construction time.
Via a subTest
from fileTestSuite.unittest import FileTestSuiteTestCaseMixin
- Create a test
class Tests(unittest.TestCase, FileTestSuiteTestCaseMixin):
@property
def fileTestSuiteDir(self) -> Path:
return thisDir / "testDataset"
def _testProcessorImpl(self, challFile: Path, respFile: Path, paramsDict: typing.Optional[dict]=None) -> None: # the signature must be this one! Note the underscore.
self._testChallengeResponsePair(challFile=challFile.read_bytes(), respFile=respFile.read_bytes(), paramsDict=paramsDict) # your function
Pros, cons: the inversion of ones of withFTS.