Files
mongo/buildscripts/resmokelib/testing/testcases/pytest.py
Steve McClure b4b23946cd SERVER-90570: Enable formatting checks for buildscripts directory, excluding idl (#22254)
GitOrigin-RevId: 9d997a9f44cd43a8dec7c2a17fa2dbcd875e92f6
2024-05-16 22:07:36 +00:00

29 lines
880 B
Python

"""The unittest.TestCase for Python unittests."""
import os
import sys
from buildscripts.resmokelib import core, logging
from buildscripts.resmokelib.testing.testcases import interface
class PyTestCase(interface.ProcessTestCase):
"""A python test to execute."""
REGISTERED_NAME = "py_test"
def __init__(self, logger: logging.Logger, py_filenames: list[str]):
"""Initialize PyTestCase."""
assert len(py_filenames) == 1
interface.ProcessTestCase.__init__(self, logger, "PyTest", py_filenames[0])
def _make_process(self):
return core.programs.generic_program(
self.logger, [sys.executable, "-m", "unittest", self.test_module_name]
)
@property
def test_module_name(self):
"""Get the dotted module name from the path."""
return os.path.splitext(self.test_name)[0].replace(os.sep, ".")