Taragolis opened a new pull request, #38730:
URL: https://github.com/apache/airflow/pull/38730

   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   This changes most attempt to fix cleanup ProviderManager, which I guess only 
use in tests.
   Right now it might keep some values between the test as result it might not 
unwrap some values.
   
   Sample for demonstrate it
   
   ```python
   class TestFoo:
       def test_http(self, cleanup_providers_manager):
           from airflow.providers_manager import ProvidersManager
   
           manager = ProvidersManager()
           hooks = manager.hooks
           info = hooks["http"]
           assert not callable(info)
           assert "http" in hooks._resolved
   
       def test_aws(self, cleanup_providers_manager):
           from airflow.providers_manager import ProvidersManager
   
           manager = ProvidersManager()
           hooks = manager.hooks
           info = hooks["aws"]
           assert not callable(info)
           assert "aws" in hooks._resolved
           assert "http" not in hooks._resolved
   
       def test_aws_again(self):
           from airflow.providers_manager import ProvidersManager
   
           manager = ProvidersManager()
           assert manager.hooks["aws"].package_name
   ```
   and result
   
   ```console
   ❯ pytest tests/test_spam.py::TestFoo
   ================================================ test session starts 
================================================
   platform darwin -- Python 3.9.10, pytest-7.4.4, pluggy-1.4.0 -- 
/Users/taragolis/.pyenv/versions/3.9.10/envs/airflow-dev-env-39/bin/python
   cachedir: .pytest_cache
   rootdir: /Users/taragolis/Projects/common/airflow
   configfile: pyproject.toml
   plugins: cov-5.0.0, instafail-0.5.0, timeouts-1.2.1, anyio-4.3.0, 
custom-exit-code-0.3.0, rerunfailures-14.0, icdiff-0.9, xdist-3.5.0, 
time-machine-2.14.1, asyncio-0.23.6, mock-3.14.0, requests-mock-1.12.1
   asyncio: mode=strict
   setup timeout: 0.0s, execution timeout: 0.0s, teardown timeout: 0.0s
   collected 3 items                                                            
                                       
   
   tests/test_spam.py::TestFoo::test_http PASSED                                
                                 [ 33%]
   tests/test_spam.py::TestFoo::test_aws FAILED                                 
                                 [ 66%]
   tests/test_spam.py::TestFoo::test_aws_again FAILED                           
                                 [100%]
   
   ===================================================== FAILURES 
======================================================
   _________________________________________________ TestFoo.test_aws 
__________________________________________________
   
   self = <tests.test_spam.TestFoo object at 0x10519ef70>, 
cleanup_providers_manager = None
   
       def test_aws(self, cleanup_providers_manager):
           from airflow.providers_manager import ProvidersManager
       
           manager = ProvidersManager()
           hooks = manager.hooks
           info = hooks["aws"]
           assert not callable(info)
           assert "aws" in hooks._resolved
   >       assert "http" not in hooks._resolved
   E       AssertionError: assert 'http' not in {'aws', 'http'}
   E        +  where {'aws', 'http'} = 
<airflow.providers_manager.LazyDictWithCache object at 0x10994dfd0>._resolved
   
   tests/test_spam.py:19: AssertionError
   ______________________________________________ TestFoo.test_aws_again 
_______________________________________________
   
   self = <tests.test_spam.TestFoo object at 0x1051bd310>
   
       def test_aws_again(self):
           from airflow.providers_manager import ProvidersManager
       
           manager = ProvidersManager()
   >       assert manager.hooks["aws"].package_name
   E       AttributeError: 'functools.partial' object has no attribute 
'package_name'
   
   tests/test_spam.py:25: AttributeError
   ============================================== short test summary info 
==============================================
   FAILED tests/test_spam.py::TestFoo::test_aws - AssertionError: assert 'http' 
not in {'aws', 'http'}
   FAILED tests/test_spam.py::TestFoo::test_aws_again - AttributeError: 
'functools.partial' object has no attribute 'package_name'
   ============================================ 2 failed, 1 passed in 1.79s 
============================================
   ```
      
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a 
newsfragment file, named `{pr_number}.significant.rst` or 
`{issue_number}.significant.rst`, in 
[newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to