Skip to content

Commit

Permalink
WIP7
Browse files Browse the repository at this point in the history
  • Loading branch information
e3rd committed Sep 25, 2024
1 parent 29753ce commit 6dac863
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from unittest.mock import patch

from attrs_configs import AttrsModel, AttrsNested, AttrsNestedRestraint
from configs import (ConstrainedEnv, FurtherEnv2, NestedDefaultedEnv,
from configs import (ConstrainedEnv, FurtherEnv2, MissingUnderscore, NestedDefaultedEnv,
NestedMissingEnv, OptionalFlagEnv, ParametrizedGeneric, SimpleEnv)
from pydantic_configs import PydModel, PydNested, PydNestedRestraint

Expand Down Expand Up @@ -318,10 +318,21 @@ def test_run_ask_for_missing(self):
with patch('sys.stdout', new_callable=StringIO) as stdout:
run(FurtherEnv2, True, ask_for_missing=True, interface=Mininterface)
self.assertEqual("", stdout.getvalue().strip())
with patch('sys.stdout', new_callable=StringIO) as stdout:
run(FurtherEnv2, True, ask_for_missing=False, interface=Mininterface)
self.assertEqual("", stdout.getvalue().strip())

def test_run_ask_for_missing_underscored(self):
# Treating underscores
form2 = """Asking the form {'token_underscore': Tag(val='', description='', annotation=<class 'str'>, name='token_underscore')}"""
with patch('sys.stdout', new_callable=StringIO) as stdout:
run(MissingUnderscore, True, interface=Mininterface)
self.assertEqual(form2, stdout.getvalue().strip())
self.sys("--token-underscore", "1") # dash used instead of an underscore

with patch('sys.stdout', new_callable=StringIO) as stdout:
run(MissingUnderscore, True, ask_for_missing=True, interface=Mininterface)
self.assertEqual("", stdout.getvalue().strip())

def test_run_config_file(self):
os.chdir("tests")
sys.argv = ["SimpleEnv.py"]
Expand Down

0 comments on commit 6dac863

Please sign in to comment.