Skip to content

Commit

Permalink
[AIRFLOW-821] Fix py3 compatibility
Browse files Browse the repository at this point in the history
iteritems() does not exist in py3.

Closes apache#2039 from bolkedebruin/AIRFLOW-821
  • Loading branch information
bolkedebruin committed Jan 31, 2017
1 parent 2b13109 commit fbb59b9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
3 changes: 2 additions & 1 deletion airflow/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import multiprocessing
import os
import signal
import six
import sys
import threading
import time
Expand Down Expand Up @@ -691,7 +692,7 @@ def update_import_errors(session, dagbag):
).delete()

# Add the errors of the processed files
for filename, stacktrace in dagbag.import_errors.iteritems():
for filename, stacktrace in six.iteritems(dagbag.import_errors):
session.add(models.ImportError(
filename=filename,
stacktrace=stacktrace))
Expand Down
8 changes: 0 additions & 8 deletions tests/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
except ImportError:
mock = None

IS_PYTHON_3_TRAVIS = sys.version_info >= (3, 0) and "TRAVIS" in os.environ

DEV_NULL = '/dev/null'
DEFAULT_DATE = datetime.datetime(2016, 1, 1)

Expand Down Expand Up @@ -1244,8 +1242,6 @@ def test_dag_catchup_option(self):
# The DR should be scheduled BEFORE now
self.assertLess(dr.execution_date, datetime.datetime.now())

@unittest.skipIf(IS_PYTHON_3_TRAVIS,
"Fails in Python 3 on Travis but not reproducible locally")
def test_add_unparseable_file_before_sched_start_creates_import_error(self):
try:
dags_folder = mkdtemp()
Expand All @@ -1266,8 +1262,6 @@ def test_add_unparseable_file_before_sched_start_creates_import_error(self):
self.assertEqual(import_error.stacktrace,
"invalid syntax ({}, line 1)".format(TEMP_DAG_FILENAME))

@unittest.skipIf(IS_PYTHON_3_TRAVIS,
"Fails in Python 3 on Travis but not reproducible locally")
def test_add_unparseable_file_after_sched_start_creates_import_error(self):
try:
dags_folder = mkdtemp()
Expand Down Expand Up @@ -1306,8 +1300,6 @@ def test_no_import_errors_with_parseable_dag(self):

self.assertEqual(len(import_errors), 0)

@unittest.skipIf(IS_PYTHON_3_TRAVIS,
"Fails in Python 3 on Travis but not reproducible locally")
def test_new_import_error_replaces_old(self):
try:
dags_folder = mkdtemp()
Expand Down

0 comments on commit fbb59b9

Please sign in to comment.