Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s
CI / tests (pull_request) Successful in 3m43s
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import contextlib
|
||||
import io
|
||||
from unittest import mock
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -18,7 +17,7 @@ class MainTest(unittest.TestCase):
|
||||
def run_main(self, argv: list[str]) -> tuple[int, str, str]:
|
||||
out, err = io.StringIO(), io.StringIO()
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||
code = main.main(argv, {}, pathlib.Path("do-epic"))
|
||||
code = main.main(argv, {}, pathlib.Path("do-epic"), sandbox.epic_made, scenario.run)
|
||||
return code, out.getvalue(), err.getvalue()
|
||||
|
||||
def test_fails_naming_each_missing_setting_before_it_touches_anything(self) -> None:
|
||||
@@ -56,10 +55,14 @@ class ReportedTest(unittest.TestCase):
|
||||
|
||||
out, err = io.StringIO(), io.StringIO()
|
||||
report = report or scenario.Report(["a check held"], ["a check broke"])
|
||||
with mock.patch.object(sandbox, "epic_made", epic_made), mock.patch.object(scenario, "run", return_value=report) as ran:
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||
code = main.main([], self.env, pathlib.Path("do-epic"))
|
||||
self.ran_with = ran.call_args.args if ran.called else None
|
||||
self.ran_with = None
|
||||
|
||||
def ran(*args: object) -> scenario.Report:
|
||||
self.ran_with = args
|
||||
return report
|
||||
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||
code = main.main([], self.env, pathlib.Path("do-epic"), epic_made, ran)
|
||||
return code, out.getvalue(), err.getvalue()
|
||||
|
||||
def test_prints_each_check_and_fails_where_one_broke(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user