-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify forward_refs_to_types to fix issue 181 (#182)
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from __future__ import annotations | ||
from simple_parsing import Serializable, ArgumentParser | ||
from dataclasses import dataclass | ||
import pytest | ||
|
||
@dataclass | ||
class MyArguments(Serializable): | ||
arg1: str = 'this_argment' | ||
|
||
@pytest.mark.parametrize( | ||
'sys_argv, result', [ | ||
(['test.py'], 'this_argment'), | ||
(['test.py', '--arg1', 'test2'], 'test2') | ||
], | ||
) | ||
def test_simple_parsing(sys_argv, result): | ||
parser = ArgumentParser() | ||
parser.add_arguments(MyArguments, 'myargs') | ||
args, _ = parser.parse_known_args(sys_argv) | ||
assert args.myargs.arg1 == result |