Python implementation of fileTestSuite spec
Find a file
2023-10-17 20:42:20 +03:00
.ci Initial commit 2023-10-17 20:42:20 +03:00
.github Initial commit 2023-10-17 20:42:20 +03:00
fileTestSuite Initial commit 2023-10-17 20:42:20 +03:00
tests Initial commit 2023-10-17 20:42:20 +03:00
.editorconfig Initial commit 2023-10-17 20:42:20 +03:00
.gitignore Initial commit 2023-10-17 20:42:20 +03:00
.gitlab-ci.yml Initial commit 2023-10-17 20:42:20 +03:00
.gitmodules Initial commit 2023-10-17 20:42:20 +03:00
Code_Of_Conduct.md Initial commit 2023-10-17 20:42:20 +03:00
logo.svg Initial commit 2023-10-17 20:42:20 +03:00
MANIFEST.in Initial commit 2023-10-17 20:42:20 +03:00
pyproject.toml Initial commit 2023-10-17 20:42:20 +03:00
ReadMe.md Initial commit 2023-10-17 20:42:20 +03:00
UNLICENSE Initial commit 2023-10-17 20:42:20 +03:00

fileTestSuite.pyUnlicensed work

wheel (GHA via nightly.link) GitHub Actions Libraries.io Status Code style: antiflash

An implementation of fileTestSuite spec for Python.

Authoring

fileTestSuiteTool --help

init

Creates a boilerplate of meta.json.

convert

  1. Create a meta.json in a dir.
  2. fileTestSuiteTool convert meta.json to convert into the binary representation
  3. fileTestSuiteTool convert meta.ftsmeta to convert the binary representation back into JSON.

Testing

Via withFTS decorator

  1. Download a suite of test files. It can be a git submodule.
from fileTestSuite.unittest import withFTS
  1. Get path of the directory of the test suite:
thisDir = Path(__file__).resolve().absolute().parent
thisDir = thisDir / "testDataset"
  1. 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
  1. 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.