Files
stack/agents/rocko/work/vikunja-502/tests/test_timeout_cause.py

45 lines
1.7 KiB
Python

"""Exercise the actual pure cause renderer without executing the mutant driver."""
import ast
from pathlib import Path
import unittest
RUNNER = Path(__file__).resolve().parents[1] / 'run-mutants.py'
def cause_renderer():
tree = ast.parse(RUNNER.read_text())
function = next(n for n in tree.body if isinstance(n, ast.FunctionDef) and n.name == 'timeout_cause')
namespace = {}
exec(compile(ast.Module(body=[function], type_ignores=[]), str(RUNNER), 'exec'), namespace)
return namespace['timeout_cause']
class TimeoutCause(unittest.TestCase):
def setUp(self):
self.cause = cause_renderer()
self.site = {'id': 'KS54', 'file': 'packages/bus/src/runtime.mjs'}
def test_missing_control_never_claims_an_unmutated_pass(self):
text = self.cause(self.site)
self.assertIn('no passing same-file control', text)
self.assertNotIn('passed unmutated', text)
def test_failed_control_never_claims_an_unmutated_pass(self):
text = self.cause(self.site, {'passed': False})
self.assertIn('no passing same-file control', text)
self.assertNotIn('passed unmutated', text)
def test_passing_control_can_state_its_observed_pass(self):
text = self.cause(self.site, {'passed': True})
self.assertIn('passed unmutated', text)
self.assertNotIn('no passing same-file control', text)
def test_known_sr08_cause_remains_specific_without_claiming_a_control(self):
text = self.cause({'id': 'SR08', 'file': 'packages/processing-control/src/runtimes.mjs'})
self.assertIn('fixed fake clock', text)
self.assertNotIn('passed unmutated', text)
if __name__ == '__main__':
unittest.main()