potiuk commented on code in PR #25780: URL: https://github.com/apache/airflow/pull/25780#discussion_r956399143
########## tests/utils/test_preexisting_python_virtualenv_decorator.py: ########## @@ -0,0 +1,52 @@ +# +# 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. +# +import unittest + +from airflow.utils.decorators import remove_task_decorator + + +class TestPreexistingPythonVirtualenvDecorator(unittest.TestCase): + def test_remove_task_decorator(self): + py_source = "@task.preexisting_virtualenv(use_dill=True)\ndef f():\nimport funcsigs" + res = remove_task_decorator( + python_source=py_source, task_decorator_name="@task.preexisting_virtualenv" + ) + assert res == "def f():\nimport funcsigs" + + def test_remove_decorator_no_parens(self): + + py_source = "@task.preexisting_virtualenv\ndef f():\nimport funcsigs" + res = remove_task_decorator( + python_source=py_source, task_decorator_name="@task.preexisting_virtualenv" + ) + assert res == "def f():\nimport funcsigs" + + def test_remove_decorator_nested(self): + + py_source = "@foo\[email protected]_virtualenv\n@bar\ndef f():\nimport funcsigs" + res = remove_task_decorator( + python_source=py_source, task_decorator_name="@task.preexisting_virtualenv" + ) + assert res == "@foo\n@bar\ndef f():\nimport funcsigs" + + py_source = "@foo\[email protected]_virtualenv()\n@bar\ndef f():\nimport funcsigs" + res = remove_task_decorator( + python_source=py_source, task_decorator_name="@task.preexisting_virtualenv" + ) + assert res == "@foo\n@bar\ndef f():\nimport funcsigs" Review Comment: Right. I love that. It was just renamed (badly) file that I did not touch. But that's OK for me to change to pytest style. I actually learned to love Pytest style of test! -- 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]
