Currently the operator allows to set requirement as list that needs to be hard coded.
It would be nice if airflow can support reading from file directly (something similar to how operators read sql file)
tests/operators/test_python.py
task = PythonVirtualenvOperator(
            python_callable=fn, python_version=python_version, task_id='task', dag=self.dag, **kwargs
        )
        task.run(start_date=DEFAULT_DATE, end_date=DEFAULT_DATE)
        return task
    def test_add_dill(self):
        def f():
            pass
        task = self._run_as_operator(f, use_dill=True, system_site_packages=False)
        assert 'dill' in task.requirements
    def test_no_requirements(self):
        """Tests that the python callable is invoked on task run."""
        def f():
            pass
        self._run_as_operator(f)
    def test_no_system_site_packages(self):
        def f():
            try:
                import funcsigs  
            except ImportError:
                return True
            raise Exception
        self._run_as_operator(f, system_site_packages=False, requirements=['dill'])
    def test_system_site_packages(self):
        def f():
            import funcsigs  
        self._run_as_operator(f, requirements=['funcsigs'], system_site_packages=True)
    def test_with_requirements_pinned(self):