[ 
https://issues.apache.org/jira/browse/AIRFLOW-3551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16727987#comment-16727987
 ] 

Felix Uellendall edited comment on AIRFLOW-3551 at 12/23/18 3:52 PM:
---------------------------------------------------------------------

I think it is not really testable because it is a inner function and I can not 
directly access it.
{code:python}
                def pre_exec():
                    # Restore default signal disposition and invoke setsid
                    for sig in ('SIGPIPE', 'SIGXFZ', 'SIGXFSZ'):
                        if hasattr(signal, sig):
                            signal.signal(getattr(signal, sig), signal.SIG_DFL)
                    os.setsid()

                self.log.info('Running command: %s', self.bash_command)
                sub_process = Popen(
                    ['bash', tmp_file.name],
                    stdout=PIPE,
                    stderr=STDOUT,
                    cwd=tmp_dir,
                    env=self.env,
                    preexec_fn=pre_exec)
{code}


was (Author: feluelle):
I think it is not really testable because it is a inner function and I can not 
directly access it.
{code:python}
                def pre_exec():
                    # Restore default signal disposition and invoke setsid
                    for sig in ('SIGPIPE', 'SIGXFZ', 'SIGXFSZ'):
                        if hasattr(signal, sig):
                            signal.signal(getattr(signal, sig), signal.SIG_DFL)
                    os.setsid()

                self.log.info('Running command: %s', self.bash_command)
                sub_process = Popen(
                    ['bash', tmp_file.name],
                    stdout=PIPE,
                    stderr=STDOUT,
                    cwd=tmp_dir,
                    env=self.env,
                    preexec_fn=pre_exec)
{code}

If we move it outside we can test it. You think the `pre_exec` function should 
be a public function in the `BaseOperator` ?


> Improve BashOperator Test Coverage
> ----------------------------------
>
>                 Key: AIRFLOW-3551
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-3551
>             Project: Apache Airflow
>          Issue Type: Test
>            Reporter: Felix Uellendall
>            Assignee: Felix Uellendall
>            Priority: Minor
>
> The current tests for the `BashOperator` are not covering
> * pre_exec
> * xcom_push_flag



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to