turbaszek commented on a change in pull request #9704:
URL: https://github.com/apache/airflow/pull/9704#discussion_r451345508



##########
File path: tests/plugins/test_plugins_manager.py
##########
@@ -94,59 +95,53 @@ def 
test_entrypoint_plugin_errors_dont_raise_exceptions(self, mock_ep_plugins):
 
 
 class TestPluginsManager(unittest.TestCase):
-    class AirflowTestPropertyPlugin(AirflowPlugin):
-        name = "test_property_plugin"
+    def test_should_load_plugins_from_property(self):
+        class AirflowTestPropertyPlugin(AirflowPlugin):
+            name = "test_property_plugin"
+
+            @property
+            def operators(self):
+                from airflow.models.baseoperator import BaseOperator
+
+                class PluginPropertyOperator(BaseOperator):
+                    pass
 
-        @property
-        def operators(self):
-            from airflow.models.baseoperator import BaseOperator
+                return [PluginPropertyOperator]
 
-            class PluginPropertyOperator(BaseOperator):
+            class TestNonPropertyHook(BaseHook):
                 pass
 
-            return [PluginPropertyOperator]
+            hooks = [TestNonPropertyHook]
 
-        class TestNonPropertyHook(BaseHook):
-            pass
+        with mock_plugin_manager(plugins=[AirflowTestPropertyPlugin()]):
+            from airflow import plugins_manager
+            plugins_manager.integrate_dag_plugins()
 
-        hooks = [TestNonPropertyHook]
+            self.assertIn('AirflowTestPropertyPlugin', 
str(plugins_manager.plugins))
+            self.assertIn('PluginPropertyOperator', 
str(plugins_manager.operators_modules[0].__dict__))
+            self.assertIn("TestNonPropertyHook", 
str(plugins_manager.hooks_modules[0].__dict__))
 
-    @mock.patch('airflow.plugins_manager.plugins', 
[AirflowTestPropertyPlugin()])
-    @mock.patch('airflow.plugins_manager.operators_modules', None)
-    @mock.patch('airflow.plugins_manager.sensors_modules', None)
-    @mock.patch('airflow.plugins_manager.hooks_modules', None)
-    @mock.patch('airflow.plugins_manager.macros_modules', None)
-    def test_should_load_plugins_from_property(self):
-        from airflow import plugins_manager
-        plugins_manager.integrate_dag_plugins()
-        self.assertIn('TestPluginsManager.AirflowTestPropertyPlugin', 
str(plugins_manager.plugins))
-        self.assertIn('PluginPropertyOperator', 
str(plugins_manager.operators_modules[0].__dict__))
-        self.assertIn("TestNonPropertyHook", 
str(plugins_manager.hooks_modules[0].__dict__))
-
-    @mock.patch('airflow.plugins_manager.plugins', [])
-    @mock.patch('airflow.plugins_manager.admin_views', None)
-    @mock.patch('airflow.plugins_manager.flask_blueprints', None)
-    @mock.patch('airflow.plugins_manager.menu_links', None)
-    @mock.patch('airflow.plugins_manager.flask_appbuilder_views', None)
-    @mock.patch('airflow.plugins_manager.flask_appbuilder_menu_links', None)
+    @mock_plugin_manager(plugins=[])

Review comment:
       Is it necessary if we use it in L136?




----------------------------------------------------------------
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.

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


Reply via email to