2018-03-27 14:30:46 -04:00
|
|
|
"""The unittest.TestCase for Python unittests."""
|
2018-04-04 14:19:19 -04:00
|
|
|
import os
|
2019-04-15 16:09:15 -04:00
|
|
|
import sys
|
2018-04-04 14:19:19 -04:00
|
|
|
|
2019-04-15 16:09:15 -04:00
|
|
|
from buildscripts.resmokelib import core
|
2018-04-04 14:19:19 -04:00
|
|
|
from buildscripts.resmokelib.testing.testcases import interface
|
|
|
|
|
|
|
|
|
|
|
2019-04-15 16:09:15 -04:00
|
|
|
class PyTestCase(interface.ProcessTestCase):
|
2018-03-27 14:30:46 -04:00
|
|
|
"""A python test to execute."""
|
2018-04-04 14:19:19 -04:00
|
|
|
|
|
|
|
|
REGISTERED_NAME = "py_test"
|
|
|
|
|
|
|
|
|
|
def __init__(self, logger, py_filename):
|
2018-03-27 14:30:46 -04:00
|
|
|
"""Initialize PyTestCase."""
|
2019-04-15 16:09:15 -04:00
|
|
|
interface.ProcessTestCase.__init__(self, logger, "PyTest", py_filename)
|
2018-04-04 14:19:19 -04:00
|
|
|
|
2019-04-15 16:09:15 -04:00
|
|
|
def _make_process(self):
|
|
|
|
|
return core.programs.generic_program(
|
|
|
|
|
self.logger, [sys.executable, "-m", "unittest", self.test_module_name])
|
2018-04-04 14:19:19 -04:00
|
|
|
|
|
|
|
|
@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, ".")
|