diff --git a/.travis.yml b/.travis.yml index bd904f5..9bbcb9f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,18 +8,18 @@ env: - TOXENV=django111 - TOXENV=django20 - TOXENV=django21 + - TOXENV=quality matrix: - include: - - python: 2.7 - env: TOXENV=quality exclude: - python: 2.7 env: TOXENV=django20 - python: 2.7 env: TOXENV=django21 - allow_failures: - python: 3.6 - - python: 3.7 + env: TOXENV=quality + allow_failures: + - env: TOXENV=django20 + - env: TOXENV=django21 services: - xvfb diff --git a/run_tests.py b/run_tests.py index 527cacf..fc05f22 100755 --- a/run_tests.py +++ b/run_tests.py @@ -4,6 +4,7 @@ Run tests for XBlock-utils """ +from __future__ import absolute_import import os import sys diff --git a/tests/integration/test_base_test.py b/tests/integration/test_base_test.py index 2014b61..9656822 100644 --- a/tests/integration/test_base_test.py +++ b/tests/integration/test_base_test.py @@ -18,6 +18,7 @@ # "AGPLv3". If not, see . # +from __future__ import absolute_import import unittest from xblockutils.base_test import SeleniumBaseTest diff --git a/tests/integration/test_studio_editable.py b/tests/integration/test_studio_editable.py index d2ec7d9..c586291 100644 --- a/tests/integration/test_studio_editable.py +++ b/tests/integration/test_studio_editable.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import datetime import textwrap import mock @@ -12,6 +13,7 @@ from xblockutils.studio_editable import StudioEditableXBlockMixin, StudioContainerWithNestedXBlocksMixin, \ NestedXBlockSpec from xblockutils.studio_editable_test import StudioEditableBaseTest, StudioContainerWithNestedXBlocksBaseTest +from six.moves import range class EditableXBlock(StudioEditableXBlockMixin, XBlock): @@ -218,6 +220,7 @@ def expect_error_message(expected_message): def fancy_list_values_provider_a(block): return [1, 2, 3, 4, 5] + def fancy_list_values_provider_b(block): return [{"display_name": "Robert", "value": "bob"}, {"display_name": "Alexandra", "value": "alex"}] diff --git a/tests/integration/utils.py b/tests/integration/utils.py index 2b33ed5..d5d509b 100644 --- a/tests/integration/utils.py +++ b/tests/integration/utils.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import from django.template import Context, Template from xblockutils.resources import ResourceLoader @@ -5,10 +6,9 @@ def render_template(template_path, context, **kwargs): - file_path = "tests/integration/template_stubs/"+template_path + file_path = "tests/integration/template_stubs/" + template_path with open(file_path, 'r') as tpl_file: template_str = tpl_file.read().replace('\n', '') template = Template(template_str) return template.render(Context(context)) - diff --git a/tests/unit/test_helpers.py b/tests/unit/test_helpers.py index f598b46..8abfa3d 100644 --- a/tests/unit/test_helpers.py +++ b/tests/unit/test_helpers.py @@ -1,6 +1,7 @@ """ Tests for helpers.py """ +from __future__ import absolute_import import unittest from workbench.runtime import WorkbenchRuntime from xblock.core import XBlock diff --git a/tests/unit/test_publish_event.py b/tests/unit/test_publish_event.py index 007a748..16df32f 100644 --- a/tests/unit/test_publish_event.py +++ b/tests/unit/test_publish_event.py @@ -18,6 +18,7 @@ # "AGPLv3". If not, see . # +from __future__ import absolute_import import unittest import json diff --git a/tests/unit/test_resources.py b/tests/unit/test_resources.py index 0afa5e7..608a416 100644 --- a/tests/unit/test_resources.py +++ b/tests/unit/test_resources.py @@ -18,6 +18,7 @@ # "AGPLv3". If not, see . # +from __future__ import absolute_import import unittest import gettext from mock import patch, DEFAULT diff --git a/tests/unit/test_settings.py b/tests/unit/test_settings.py index 9c00677..711c253 100644 --- a/tests/unit/test_settings.py +++ b/tests/unit/test_settings.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import unittest import ddt import itertools diff --git a/tox.ini b/tox.ini index 9abca31..9ec2407 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ envlist = py{27,36,37}-django{111,20,21} # We catch this with pylint, don't need 2 reports of the same issue # E722: do not use bare except, specify exception instead # We catch this with pylint, don't need 2 reports of the same issue -ignore=E402,E722 +ignore=E402,E722,W504 exclude=.tox/ max-line-length = 120 @@ -39,6 +39,6 @@ deps = commands = {[base]commands} pip install Django>=1.11,<2.2 - pycodestyle xblockutils + pycodestyle . pylint xblockutils python setup.py check -r -s diff --git a/xblockutils/base_test.py b/xblockutils/base_test.py index 8eb4139..5d04ea3 100644 --- a/xblockutils/base_test.py +++ b/xblockutils/base_test.py @@ -21,6 +21,7 @@ Base classes for Selenium or bok-choy based integration tests of XBlocks. """ +from __future__ import absolute_import import time from selenium.webdriver.support.ui import WebDriverWait diff --git a/xblockutils/publish_event.py b/xblockutils/publish_event.py index d4431c9..2d9a11d 100644 --- a/xblockutils/publish_event.py +++ b/xblockutils/publish_event.py @@ -21,6 +21,7 @@ PublishEventMixin: A mixin for publishing events from an XBlock """ +from __future__ import absolute_import from xblock.core import XBlock diff --git a/xblockutils/resources.py b/xblockutils/resources.py index 1033146..ca38eaa 100644 --- a/xblockutils/resources.py +++ b/xblockutils/resources.py @@ -22,6 +22,7 @@ """ +from __future__ import absolute_import import os import sys import warnings diff --git a/xblockutils/settings.py b/xblockutils/settings.py index a990ef5..579a597 100644 --- a/xblockutils/settings.py +++ b/xblockutils/settings.py @@ -5,6 +5,7 @@ """ This module contains a mixins that allows third party XBlocks to access Settings Service in edX LMS. """ +from __future__ import absolute_import from xblockutils.resources import ResourceLoader diff --git a/xblockutils/studio_editable.py b/xblockutils/studio_editable.py index b97fa7f..827b89b 100644 --- a/xblockutils/studio_editable.py +++ b/xblockutils/studio_editable.py @@ -10,9 +10,11 @@ # Imports ########################################################### +from __future__ import absolute_import import json import logging +import six from six import text_type from xblock.core import XBlock @@ -226,7 +228,7 @@ def submit_studio_edits(self, data, suffix=''): ) self.validate_field_data(validation, preview_data) if validation: - for field_name, value in values.iteritems(): + for field_name, value in six.iteritems(values): setattr(self, field_name, value) for field_name in to_reset: self.fields[field_name].delete_from(self) diff --git a/xblockutils/studio_editable_test.py b/xblockutils/studio_editable_test.py index 5abc03c..1662abf 100644 --- a/xblockutils/studio_editable_test.py +++ b/xblockutils/studio_editable_test.py @@ -1,6 +1,7 @@ """ Tests for StudioEditableXBlockMixin """ +from __future__ import absolute_import from selenium.webdriver.support.ui import WebDriverWait from xblockutils.base_test import SeleniumXBlockTest diff --git a/xblockutils/templatetags/i18n.py b/xblockutils/templatetags/i18n.py index 64d86c1..48a545c 100644 --- a/xblockutils/templatetags/i18n.py +++ b/xblockutils/templatetags/i18n.py @@ -3,6 +3,7 @@ Based on: https://github.com/eduNEXT/django-xblock-i18n """ +from __future__ import absolute_import from contextlib import contextmanager from django.template import Library, Node