Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Context' object has no attribute '_ctx_mgr' #30

Open
bnavigator opened this issue Jan 18, 2024 · 2 comments
Open

AttributeError: 'Context' object has no attribute '_ctx_mgr' #30

bnavigator opened this issue Jan 18, 2024 · 2 comments

Comments

@bnavigator
Copy link

The most recent change between 8.1.7.0 and 8.1.7.1 causes the unit tests to fail:

bae29c3#r137383936

[   31s] =================================== FAILURES ===================================
[   31s] ________________________ test_context_pushing[asyncio] _________________________
[   31s] 
[   31s]     @pytest.mark.anyio
[   31s]     async def test_context_pushing():
[   31s]         rv = []
[   31s]     
[   31s]         @click.command()
[   31s]         def cli():
[   31s]             pass
[   31s]     
[   31s]         ctx = click.Context(cli)
[   31s]     
[   31s]         @ctx.call_on_close
[   31s] >       def test_callback():
[   31s] 
[   31s] tests/test_context.py:190: 
[   31s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   31s] 
[   31s] self = <asyncclick.core.Context object at 0x7f0a5bf1c700>
[   31s] f = <function test_context_pushing.<locals>.test_callback at 0x7f0a5bf115e0>
[   31s] 
[   31s]     def call_on_close(self, f: t.Callable[..., t.Any]) -> t.Callable[..., t.Any]:
[   31s]         """Register a function to be called when the context tears down.
[   31s]     
[   31s]         This can be used to close resources opened during the script
[   31s]         execution. Resources that support Python's context manager
[   31s]         protocol which would be used in a ``with`` statement should be
[   31s]         registered with :meth:`with_resource` instead.
[   31s]     
[   31s]         :param f: The function to execute on teardown.
[   31s]         """
[   31s] >       return self._ctx_mgr.callback(f)
[   31s] E       AttributeError: 'Context' object has no attribute '_ctx_mgr'
[   31s] 
[   31s] ../../BUILDROOT/python-asyncclick-8.1.7.1-0.x86_64/usr/lib/python3.9/site-packages/asyncclick/core.py:627: AttributeError
[   31s] __________________________ test_context_pushing[trio] __________________________
[   31s] 
[   31s]     @pytest.mark.anyio
[   31s]     async def test_context_pushing():
[   31s]         rv = []
[   31s]     
[   31s]         @click.command()
[   31s]         def cli():
[   31s]             pass
[   31s]     
[   31s]         ctx = click.Context(cli)
[   31s]     
[   31s]         @ctx.call_on_close
[   31s] >       def test_callback():
[   31s] 
[   31s] tests/test_context.py:190: 
[   31s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   31s] 
[   31s] self = <asyncclick.core.Context object at 0x7f0a602bc850>
[   31s] f = <function test_context_pushing.<locals>.test_callback at 0x7f0a602a9820>
[   31s] 
[   31s]     def call_on_close(self, f: t.Callable[..., t.Any]) -> t.Callable[..., t.Any]:
[   31s]         """Register a function to be called when the context tears down.
[   31s]     
[   31s]         This can be used to close resources opened during the script
[   31s]         execution. Resources that support Python's context manager
[   31s]         protocol which would be used in a ``with`` statement should be
[   31s]         registered with :meth:`with_resource` instead.
[   31s]     
[   31s]         :param f: The function to execute on teardown.
[   31s]         """
[   31s] >       return self._ctx_mgr.callback(f)
[   31s] E       AttributeError: 'Context' object has no attribute '_ctx_mgr'
[   31s] 
[   31s] ../../BUILDROOT/python-asyncclick-8.1.7.1-0.x86_64/usr/lib/python3.9/site-packages/asyncclick/core.py:627: AttributeError
[   31s] =========================== short test summary info ============================

click.Context does not have that attribute.

@cpina
Copy link

cpina commented Feb 29, 2024

I confirm: same problem here at the moment!

@smurfix
Copy link
Collaborator

smurfix commented Mar 10, 2024

Should be fixed with 8.1.7.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants