Files
mongo/buildscripts/resmokelib/testing/testcases/pytest.py
Trevor Guidry 2c6a074835 SERVER-120178 add unixDomainSocket support to resmoke (#49009)
GitOrigin-RevId: 8fd583254ad9b50caada6a025661200141608b8e
2026-03-06 16:21:18 +00:00

33 lines
1.1 KiB
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):
program_options = {}
interface.append_process_tracking_options(program_options, self._id)
# Merge fixture environment variables into program_options
self._merge_fixture_environment_variables(program_options)
return core.programs.generic_program(
self.logger, [sys.executable, "-m", "unittest", self.test_module_name], program_options
)
@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, ".")