Skip to content

Commit

Permalink
adds invoke_tests for conditional pytest or unittest usage; makes tes…
Browse files Browse the repository at this point in the history
…t class sub-class of TestWrapper; uses setupClass to set script_module/file
  • Loading branch information
tomasohara committed Jan 16, 2024
1 parent a5091bf commit 8f51680
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions mezcla/tests/test_os_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,28 @@
# Local packages
from mezcla import debug
from mezcla import os_utils
from mezcla.unittest_wrapper import TestWrapper, invoke_tests

# Note: Two references are used for the module to be tested:
# THE_MODULE: global module object
## TODO: import mezcla.os_utils as THE_MODULE
# THE_MODULE: global module object
# TestWrapper.script_module: path to file
THE_MODULE = os_utils

class TestOsUtils:
class TestOsUtils(TestWrapper):
"""Class for testcase definition"""

@classmethod
def setupClass(cls):
"""Per-class initialization""" # why not docstring inherited (or pylint bug?)
debug.trace(5, f"TestOsUtils.setupClass({cls})")
debug.trace_expr(5, __file__, THE_MODULE)
super().setUpClass(filename=__file__, module=THE_MODULE)

def test_split_extension(self):
"""Ensure test_split_extension works as expected"""
assert(os_utils.split_extension("fubar.txt") == ("fubar", ".txt"))


if __name__ == '__main__':
debug.trace_current_context()
pytest.main([__file__])
invoke_tests([__file__])

0 comments on commit 8f51680

Please sign in to comment.