fix: tests, imports

This commit is contained in:
2025-10-11 19:37:23 +03:00
parent e481ee8775
commit 2b76bea318
5 changed files with 26 additions and 9 deletions
@@ -3,6 +3,7 @@ from unittest.mock import patch, MagicMock
from unittest import TestCase
import io
import re
import sys
from argenta.command import Command, PredefinedFlags
from argenta.command.flag.models import ValidationStatus
@@ -11,8 +12,15 @@ from argenta import Orchestrator, App, Router
from argenta.response import Response
class PatchedArgvTestCase(TestCase):
def setUp(self):
super().setUp()
self.patcher = patch.object(sys, 'argv', ['program.py'])
self.mock_argv = self.patcher.start()
self.addCleanup(self.patcher.stop)
class TestSystemHandlerNormalWork(TestCase):
class TestSystemHandlerNormalWork(PatchedArgvTestCase):
@patch("builtins.input", side_effect=["help", "q"])
@patch("sys.stdout", new_callable=io.StringIO)
def test_input_incorrect_command(self, mock_stdout: _io.StringIO, magick_mock: MagicMock):
@@ -3,6 +3,7 @@ from unittest.mock import patch, MagicMock
from unittest import TestCase
import io
import re
import sys
from argenta.command import Command, PredefinedFlags
from argenta.command.flag.models import PossibleValues, ValidationStatus
@@ -12,8 +13,15 @@ from argenta.command.flag import Flag
from argenta.command.flag.flags import Flags
class PatchedArgvTestCase(TestCase):
def setUp(self):
super().setUp()
self.patcher = patch.object(sys, 'argv', ['program.py'])
self.mock_argv = self.patcher.start()
self.addCleanup(self.patcher.stop)
class TestSystemHandlerNormalWork(TestCase):
class TestSystemHandlerNormalWork(PatchedArgvTestCase):
@patch("builtins.input", side_effect=["test", "q"])
@patch("sys.stdout", new_callable=io.StringIO)
def test_input_correct_command(self, mock_stdout: _io.StringIO, magick_mock: MagicMock):