From f10df9dd5eb7a39b758c8853ee8fd9a0a78bce31 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Fri, 20 Sep 2019 16:30:15 +0500 Subject: [PATCH 1/2] BOM-581 Fixing python3 --- openedx/core/djangoapps/embargo/tests/test_forms.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/openedx/core/djangoapps/embargo/tests/test_forms.py b/openedx/core/djangoapps/embargo/tests/test_forms.py index 59845239b9..e4d51b7e10 100644 --- a/openedx/core/djangoapps/embargo/tests/test_forms.py +++ b/openedx/core/djangoapps/embargo/tests/test_forms.py @@ -111,16 +111,15 @@ class IPFilterFormTest(TestCase): def test_add_invalid_ips(self): # test adding invalid ip addresses form_data = { - 'whitelist': u'.0.0.1, :dead:beef:::, 1.0.0.0/55', - 'blacklist': u' 18.244.* , 999999:c0a8:101::42, 1.0.0.0/' + 'whitelist': '.0.0.1, :dead:beef:::, 1.0.0.0/55', + 'blacklist': ' 18.244.* , 999999:c0a8:101::42, 1.0.0.0/' } form = IPFilterForm(data=form_data) self.assertFalse(form.is_valid()) - - wmsg = "Invalid IP Address(es): [u'.0.0.1', u':dead:beef:::', u'1.0.0.0/55']" \ + wmsg = "Invalid IP Address(es): ['.0.0.1', ':dead:beef:::', '1.0.0.0/55']" \ " Please fix the error(s) and try again." self.assertEquals(wmsg, form._errors['whitelist'][0]) # pylint: disable=protected-access - bmsg = "Invalid IP Address(es): [u'18.244.*', u'999999:c0a8:101::42', u'1.0.0.0/']" \ + bmsg = "Invalid IP Address(es): ['18.244.*', '999999:c0a8:101::42', '1.0.0.0/']" \ " Please fix the error(s) and try again." self.assertEquals(bmsg, form._errors['blacklist'][0]) # pylint: disable=protected-access From 62595bba753a60f1d83649a6a5e3bebaba0730b2 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Fri, 20 Sep 2019 18:32:22 +0500 Subject: [PATCH 2/2] BOM-581 Fixing python3 --- .../djangoapps/embargo/tests/test_forms.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/openedx/core/djangoapps/embargo/tests/test_forms.py b/openedx/core/djangoapps/embargo/tests/test_forms.py index e4d51b7e10..7f8359b4d5 100644 --- a/openedx/core/djangoapps/embargo/tests/test_forms.py +++ b/openedx/core/djangoapps/embargo/tests/test_forms.py @@ -111,16 +111,26 @@ class IPFilterFormTest(TestCase): def test_add_invalid_ips(self): # test adding invalid ip addresses form_data = { - 'whitelist': '.0.0.1, :dead:beef:::, 1.0.0.0/55', - 'blacklist': ' 18.244.* , 999999:c0a8:101::42, 1.0.0.0/' + 'whitelist': u'.0.0.1, :dead:beef:::, 1.0.0.0/55', + 'blacklist': u' 18.244.* , 999999:c0a8:101::42, 1.0.0.0/' } form = IPFilterForm(data=form_data) self.assertFalse(form.is_valid()) - wmsg = "Invalid IP Address(es): ['.0.0.1', ':dead:beef:::', '1.0.0.0/55']" \ - " Please fix the error(s) and try again." + + if six.PY2: + wmsg = "Invalid IP Address(es): [u'.0.0.1', u':dead:beef:::', u'1.0.0.0/55']" \ + " Please fix the error(s) and try again." + else: + wmsg = "Invalid IP Address(es): ['.0.0.1', ':dead:beef:::', '1.0.0.0/55']" \ + " Please fix the error(s) and try again." self.assertEquals(wmsg, form._errors['whitelist'][0]) # pylint: disable=protected-access - bmsg = "Invalid IP Address(es): ['18.244.*', '999999:c0a8:101::42', '1.0.0.0/']" \ - " Please fix the error(s) and try again." + + if six.PY2: + bmsg = "Invalid IP Address(es): [u'18.244.*', u'999999:c0a8:101::42', u'1.0.0.0/']" \ + " Please fix the error(s) and try again." + else: + bmsg = "Invalid IP Address(es): ['18.244.*', '999999:c0a8:101::42', '1.0.0.0/']" \ + " Please fix the error(s) and try again." self.assertEquals(bmsg, form._errors['blacklist'][0]) # pylint: disable=protected-access with self.assertRaisesRegexp(ValueError, "The IPFilter could not be created because the data didn't validate."):