test(inspect): import unittest one way in the inspection suites
Code scanning flagged the mixed 'import unittest' and 'from unittest import mock' forms. Use 'import unittest' plus 'import unittest.mock' everywhere.
This commit is contained in:
@@ -10,6 +10,7 @@ import io
|
||||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
import unittest.mock
|
||||
import zlib
|
||||
from pathlib import Path
|
||||
|
||||
@@ -210,12 +211,11 @@ class TestOverwrittenPromptManagerText(unittest.TestCase):
|
||||
|
||||
def test_the_workflow_is_parsed_only_for_prompt_manager_graphs(self):
|
||||
# Review M-4: no PromptManager-like node, no workflow parse.
|
||||
from unittest import mock
|
||||
|
||||
from utils import prompt_inspector
|
||||
|
||||
prompt = parity.build("f02")["prompt"]
|
||||
with mock.patch.object(
|
||||
with unittest.mock.patch.object(
|
||||
prompt_inspector,
|
||||
"_parsed_workflow",
|
||||
wraps=prompt_inspector._parsed_workflow,
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
import ast
|
||||
import json
|
||||
import unittest
|
||||
import unittest.mock
|
||||
from pathlib import Path
|
||||
from dataclasses import replace
|
||||
from unittest import mock
|
||||
|
||||
from utils import prompt_pair_resolver
|
||||
from utils.inspection_outcomes import (
|
||||
@@ -235,7 +235,7 @@ class TestOutcomeMessages(unittest.TestCase):
|
||||
"reason_code": None,
|
||||
"node": None,
|
||||
}
|
||||
with mock.patch(
|
||||
with unittest.mock.patch(
|
||||
"utils.prompt_inspector.resolve_prompt_pair", return_value=resolved
|
||||
):
|
||||
evidence = inspect_prompt_evidence({"prompt": {}})
|
||||
|
||||
@@ -9,9 +9,9 @@ import copy
|
||||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
import unittest.mock
|
||||
from pathlib import Path
|
||||
from types import MappingProxyType
|
||||
from unittest import mock
|
||||
|
||||
from utils import inspection_semantics as semantics
|
||||
from utils.inspection_semantics import SemanticsError, load_semantics
|
||||
@@ -700,7 +700,9 @@ class ValidationTest(_TableCase):
|
||||
self.assertIn("nest", str(caught.exception))
|
||||
self.assertGreater(semantics.MAX_NESTING, _depth(json.loads(TABLE.read_text())))
|
||||
# Whichever interpreter limit the parser hits, it is a SemanticsError.
|
||||
with mock.patch.object(semantics.json, "loads", side_effect=RecursionError):
|
||||
with unittest.mock.patch.object(
|
||||
semantics.json, "loads", side_effect=RecursionError
|
||||
):
|
||||
with self.assertRaises(SemanticsError) as caught:
|
||||
self.load_doc(_minimal())
|
||||
self.assertIn("nests deeper", str(caught.exception))
|
||||
|
||||
Reference in New Issue
Block a user