-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: replace namedtuple Param with inspect.Parameter
- Loading branch information
1 parent
73e4f08
commit 545cb80
Showing
11 changed files
with
140 additions
and
155 deletions.
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
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
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
Empty file.
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,47 @@ | ||
import inspect | ||
|
||
import pytest | ||
|
||
from arger import Arger, Argument, Option | ||
from arger.docstring import ParamDocTp | ||
from arger.funcs import _EMPTY, FlagsGenerator, create_argument, create_option | ||
|
||
|
||
@pytest.fixture | ||
def param_doc(hlp=''): | ||
return ParamDocTp.init('', hlp) | ||
|
||
|
||
@pytest.fixture | ||
def parameter(name, tp=_EMPTY, default=_EMPTY): | ||
return inspect.Parameter( | ||
name, | ||
inspect.Parameter.POSITIONAL_OR_KEYWORD, | ||
annotation=tp, | ||
default=default, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def argument(parameter, param_doc) -> Argument: | ||
return create_argument(parameter, param_doc) | ||
|
||
|
||
@pytest.fixture | ||
def add_arger(): | ||
def _add(argument): | ||
par = Arger() | ||
argument.add(par) | ||
return par | ||
|
||
return _add | ||
|
||
|
||
@pytest.fixture | ||
def gen_options(): | ||
return FlagsGenerator() | ||
|
||
|
||
@pytest.fixture | ||
def option(parameter, param_doc, gen_options) -> Option: | ||
return create_option(parameter, param_doc, gen_options) |
Oops, something went wrong.