jmcarp commented on a change in pull request #4828: [AIRFLOW-4002] Optionally open debugger on errors in airflow test. URL: https://github.com/apache/airflow/pull/4828#discussion_r262790183
########## File path: airflow/bin/cli.py ########## @@ -686,10 +687,24 @@ def test(args, dag=None): task.params.update(passed_in_params) ti = TaskInstance(task, args.execution_date) - if args.dry_run: - ti.dry_run() - else: - ti.run(ignore_task_deps=True, ignore_ti_state=True, test_mode=True) + try: + if args.dry_run: + ti.dry_run() + else: + ti.run(ignore_task_deps=True, ignore_ti_state=True, test_mode=True) + except Exception: + if args.post_mortem: + debugger = get_debugger() + debugger.post_mortem() + else: + raise + + +def get_debugger(): + try: + return importlib.import_module("ipdb") + except ImportError: + return importlib.import_module("pdb") Review comment: Agreed, I factored this back into the `test` function. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services