Skip to content

Commit c675c66

Browse files
Andreas Maieryoavram
authored andcommitted
Added support for context manager 'as' clause.
Signed-off-by: Andreas Maier <andras.r.maier@gmx.de>
1 parent 26e9544 commit c675c66

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

click_spinner/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def init_spin(self):
3232

3333
def __enter__(self):
3434
self.start()
35+
return self
3536

3637
def __exit__(self, exc_type, exc_val, exc_tb):
3738
self.stop()

tests/test_spinner.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,15 @@ def cli():
7878
result = runner.invoke(cli, [])
7979
assert result.exception is None
8080

81+
82+
def test_spinner_as():
83+
@click.command()
84+
def cli():
85+
spinner = click_spinner.spinner()
86+
with spinner as sp:
87+
assert sp == spinner
88+
89+
runner = CliRunner()
90+
result = runner.invoke(cli, [])
91+
assert result.exception is None
92+

0 commit comments

Comments
 (0)