diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f6772ece31b42ba320ab901adeb11dbed210d06..ee948cfa607e312d2fe325c0b1f0d864d3cfa7fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,8 +21,6 @@ Python 3 Expensive: coverage: '/TOTAL.+ ([0-9]{1,3}%)/' variables: CODECOV_TOKEN: "895e3bf2-cfd0-45f8-9a14-4b7bd148f76d" - # tested on Travis for now, fails with odd, non-reproducible failure - allow_failure: true Python 3 CLI Tool: script: diff --git a/course/utils.py b/course/utils.py index 1b3ef424cb3239ead79261e763aba65b83236df0..68468fe86ff1020fa7b8e1cdc7bd420fc721de76 100644 --- a/course/utils.py +++ b/course/utils.py @@ -1084,8 +1084,13 @@ def csv_data_importable(file_contents, column_idx_list, header_count): err_msg += ": " err_msg += err_str - if "line contains NULL byte" in err_str: + if "line contains NUL" in err_str: err_msg = err_msg.rstrip(".") + ". " + + # This message changed over time. + # Make the message uniform to please the tests. + err_msg = err_msg.replace("NULL byte", "NUL") + err_msg += _("Are you sure the file is a CSV file other " "than a Microsoft Excel file?") diff --git a/tests/test_grades/test_csv.py b/tests/test_grades/test_csv.py index 2cc6337a5ebdf249ed3da2d89e3c97154fbf94ff..acbe0cdeedb178ae2ad39405645ea2e171ddf1f6 100644 --- a/tests/test_grades/test_csv.py +++ b/tests/test_grades/test_csv.py @@ -413,7 +413,8 @@ class ImportGradesTest(GradesTestMixin, TestCase): def test_import_file_error(self): expected_file_error_msg = ( - "Error: line contains NUL") + "Error: line contains NUL. Are you sure the file is a " + "CSV file other than a Microsoft Excel file?") with open( os.path.join(CSV_PATH, 'test_import_excel_failed.xlsx'), diff --git a/tests/utils.py b/tests/utils.py index 294b55346151c20a82fdc785fa99a953ed003334..760e4639f6fb74f2e25f5492593d6af66108d604 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -22,6 +22,13 @@ except ImportError: # Since Django >= 2.0 only support PY3 from unittest import mock # noqa + if sys.version_info < (3, 8): + # __round__ is missing from MagicMock before Py3.8 + # https://github.com/python/cpython/pull/6880 + # Work around this by monkeypatching mock: + mock._magics.add("__round__") + mock._all_magics = mock._magics | mock._non_defaults + # {{{ These are copied (and maybe modified) from django official unit tests class BaseEmailBackendTestsMixin(object):