|
1 | 1 | import os |
2 | 2 | import unittest |
| 3 | +from unittest import mock |
3 | 4 |
|
4 | 5 | from application import create_app, sqla |
5 | 6 | from application.utils import answer_feedback as af |
6 | 7 |
|
7 | 8 |
|
8 | 9 | class AnswerFeedbackTest(unittest.TestCase): |
9 | 10 | def setUp(self) -> None: |
10 | | - os.environ["NO_LOAD_GRAPH_DB"] = "1" |
| 11 | + patcher = mock.patch.dict(os.environ, {"NO_LOAD_GRAPH_DB": "1"}) |
| 12 | + patcher.start() |
| 13 | + self.addCleanup(patcher.stop) |
11 | 14 | self.app = create_app(mode="test") |
12 | 15 | self.ctx = self.app.app_context() |
13 | 16 | self.ctx.push() |
@@ -82,7 +85,9 @@ def test_attach_answer_id_adds_id_only_when_logged(self) -> None: |
82 | 85 |
|
83 | 86 | class McpRatingTest(unittest.TestCase): |
84 | 87 | def setUp(self) -> None: |
85 | | - os.environ["NO_LOAD_GRAPH_DB"] = "1" |
| 88 | + patcher = mock.patch.dict(os.environ, {"NO_LOAD_GRAPH_DB": "1"}) |
| 89 | + patcher.start() |
| 90 | + self.addCleanup(patcher.stop) |
86 | 91 | self.app = create_app(mode="test") |
87 | 92 | self.ctx = self.app.app_context() |
88 | 93 | self.ctx.push() |
@@ -126,7 +131,9 @@ def test_rate_tool_is_listed_and_dispatches(self) -> None: |
126 | 131 |
|
127 | 132 | class RestFeedbackTest(unittest.TestCase): |
128 | 133 | def setUp(self) -> None: |
129 | | - os.environ["NO_LOAD_GRAPH_DB"] = "1" |
| 134 | + patcher = mock.patch.dict(os.environ, {"NO_LOAD_GRAPH_DB": "1"}) |
| 135 | + patcher.start() |
| 136 | + self.addCleanup(patcher.stop) |
130 | 137 | self.app = create_app(mode="test") |
131 | 138 | self.ctx = self.app.app_context() |
132 | 139 | self.ctx.push() |
|
0 commit comments