mongo/buildscripts/resmokelib/testing/testcases/pytest.py
Trevor Guidry 6fa6d77e0b SERVER-121737 Add fixture and hook support to external resmoke modules (#49689)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
GitOrigin-RevId: ed84084a285fbfdb493480f5a5a6b633c703017f
2026-03-17 14:54:06 +00:00

27 lines
966 B
Python

"""The unittest.TestCase for Python unittests."""
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], **kwargs):
"""Initialize PyTestCase."""
assert len(py_filenames) == 1
interface.ProcessTestCase.__init__(self, logger, "PyTest", py_filenames[0], **kwargs)
def _make_process(self):
program_options = {}
interface.append_process_tracking_options(program_options, self._id)
# Merge test and fixture environment variables into program_options
self._merge_environment_variables(program_options)
return core.programs.generic_program(
self.logger, [sys.executable, "-m", "unittest", self.test_name], program_options
)