-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from jwodder/more-async
Test against & document support for asyncclick
- Loading branch information
Showing
12 changed files
with
367 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import logging | ||
import asyncclick as click | ||
from click_loglevel import LogLevel | ||
|
||
|
||
@click.command() | ||
@click.option( | ||
"-l", | ||
"--log-level", | ||
type=LogLevel(extra={"VERBOSE": 15, "NOTICE": 25}), | ||
) | ||
async def main(log_level: int) -> None: | ||
click.echo(repr(log_level)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,17 @@ | ||
import logging | ||
import asyncclick as click | ||
from click_loglevel import LogLevel | ||
|
||
|
||
@click.command() | ||
@click.option( | ||
"-l", | ||
"--log-level", | ||
type=LogLevel(extra={"Verbose": 15, "Notice": 25}), | ||
) | ||
async def main(log_level: int) -> None: | ||
click.echo(repr(log_level)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,16 @@ | ||
import logging | ||
import asyncclick as click | ||
from click_loglevel import LogLevel | ||
|
||
logging.addLevelName(15, "VERBOSE") | ||
logging.addLevelName(25, "NOTICE") | ||
|
||
|
||
@click.command() | ||
@click.option("-l", "--log-level", type=LogLevel(extra=["VERBOSE", "NOTICE"])) | ||
async def main(log_level: int) -> None: | ||
click.echo(repr(log_level)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,16 @@ | ||
import logging | ||
import asyncclick as click | ||
from click_loglevel import LogLevel | ||
|
||
logging.addLevelName(15, "Verbose") | ||
logging.addLevelName(25, "Notice") | ||
|
||
|
||
@click.command() | ||
@click.option("-l", "--log-level", type=LogLevel(extra=["Verbose", "Notice"])) | ||
async def main(log_level: int) -> None: | ||
click.echo(repr(log_level)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,52 @@ | ||
from __future__ import annotations | ||
import pytest | ||
from click_loglevel import LogLevel | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"incomplete,completions", | ||
[ | ||
("IN", ["INFO"]), | ||
("in", ["INFO"]), | ||
("In", ["INFO"]), | ||
("info", ["INFO"]), | ||
("i", ["INFO"]), | ||
("w", ["WARNING"]), | ||
("n", ["NOTSET"]), | ||
("D", ["DEBUG"]), | ||
("E", ["ERROR"]), | ||
("c", ["CRITICAL"]), | ||
("Q", []), | ||
("v", []), | ||
("INFOS", []), | ||
], | ||
) | ||
def test_get_completions(incomplete: str, completions: list[str]) -> None: | ||
ll = LogLevel() | ||
assert list(ll.get_completions(incomplete)) == completions | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"incomplete,completions", | ||
[ | ||
("IN", ["INFO"]), | ||
("in", ["INFO"]), | ||
("In", ["INFO"]), | ||
("info", ["INFO"]), | ||
("i", ["INFO"]), | ||
("w", ["WARNING"]), | ||
("n", ["NOTSET", "NOTICE"]), | ||
("NOT", ["NOTSET", "NOTICE"]), | ||
("NOTS", ["NOTSET"]), | ||
("NOTI", ["NOTICE"]), | ||
("D", ["DEBUG"]), | ||
("E", ["ERROR"]), | ||
("c", ["CRITICAL"]), | ||
("Q", []), | ||
("v", ["VERBOSE"]), | ||
("INFOS", []), | ||
], | ||
) | ||
def test_get_completions_extra(incomplete: str, completions: list[str]) -> None: | ||
ll = LogLevel(extra={"Verbose": 5, "Notice": 25}) | ||
assert list(ll.get_completions(incomplete)) == completions |
Oops, something went wrong.