From cf458c721e763bf6b1e82ce7fabe015153ecbe2e Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 18 Sep 2019 19:33:28 -0500 Subject: [PATCH 1/4] Work around bpo-33516: MagicMock is missing __round__ --- tests/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/utils.py b/tests/utils.py index 294b5534..760e4639 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): -- GitLab From 9127ca84661bb7772676338f401ecdab9b7d8974 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 18 Sep 2019 19:54:51 -0500 Subject: [PATCH 2/4] Revert "Fix CSV import error message" This reverts commit 6dc8e40a232e91b1e315325492e4df1cb40e3063. --- tests/test_grades/test_csv.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_grades/test_csv.py b/tests/test_grades/test_csv.py index 2cc6337a..9fceb06c 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 NULL byte. 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'), -- GitLab From 8517b925c305fd8d210357eedf5f62a76789f4da Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 18 Sep 2019 19:57:17 -0500 Subject: [PATCH 3/4] Fix error message generation for NULs in CSVs --- course/utils.py | 7 ++++++- tests/test_grades/test_csv.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/course/utils.py b/course/utils.py index 1b3ef424..68468fe8 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 9fceb06c..acbe0cde 100644 --- a/tests/test_grades/test_csv.py +++ b/tests/test_grades/test_csv.py @@ -413,7 +413,7 @@ class ImportGradesTest(GradesTestMixin, TestCase): def test_import_file_error(self): expected_file_error_msg = ( - "Error: line contains NULL byte. Are you sure the file is a " + "Error: line contains NUL. Are you sure the file is a " "CSV file other than a Microsoft Excel file?") with open( -- GitLab From e4e738c807e56c8480a6546ebe7b63c6748eabbf Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Wed, 18 Sep 2019 20:13:57 -0500 Subject: [PATCH 4/4] Remove allow_failure from Gitlab CI --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6f6772ec..ee948cfa 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: -- GitLab