From 7441702adecd95cfc0a26099ed96ef9245b4968c Mon Sep 17 00:00:00 2001
From: Usman Khalid <2200617@gmail.com>
Date: Wed, 3 Mar 2021 01:03:36 +0500
Subject: [PATCH] test: The exception on the pytest ExceptionInfo object can be
 accessed on the value attribute.

---
 common/lib/capa/capa/safe_exec/tests/test_safe_exec.py | 2 +-
 common/lib/capa/capa/tests/test_responsetypes.py       | 2 +-
 common/lib/xmodule/xmodule/tests/test_course_module.py | 2 +-
 common/lib/xmodule/xmodule/tests/test_graders.py       | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/lib/capa/capa/safe_exec/tests/test_safe_exec.py b/common/lib/capa/capa/safe_exec/tests/test_safe_exec.py
index e8f62159956..68db41feec9 100644
--- a/common/lib/capa/capa/safe_exec/tests/test_safe_exec.py
+++ b/common/lib/capa/capa/safe_exec/tests/test_safe_exec.py
@@ -77,7 +77,7 @@ class TestSafeExec(unittest.TestCase):  # lint-amnesty, pylint: disable=missing-
         g = {}
         with pytest.raises(SafeExecException) as cm:
             safe_exec("1/0", g)
-        assert 'ZeroDivisionError' in text_type(cm.exception)
+        assert 'ZeroDivisionError' in text_type(cm.value)
 
 
 class TestSafeOrNot(unittest.TestCase):  # lint-amnesty, pylint: disable=missing-class-docstring
diff --git a/common/lib/capa/capa/tests/test_responsetypes.py b/common/lib/capa/capa/tests/test_responsetypes.py
index ec7146d9d6a..bf1f9dcf31b 100644
--- a/common/lib/capa/capa/tests/test_responsetypes.py
+++ b/common/lib/capa/capa/tests/test_responsetypes.py
@@ -798,7 +798,7 @@ class StringResponseTest(ResponseTest):  # pylint: disable=missing-class-docstri
         problem = self.build_problem(answer="a2", case_sensitive=False, regexp=True, additional_answers=['?\\d?'])
         with pytest.raises(Exception) as cm:
             self.assert_grade(problem, "a3", "correct")
-        exception_message = text_type(cm.exception)
+        exception_message = text_type(cm.value)
         assert 'nothing to repeat' in exception_message
 
     def test_hints(self):
diff --git a/common/lib/xmodule/xmodule/tests/test_course_module.py b/common/lib/xmodule/xmodule/tests/test_course_module.py
index 7d75c2d1268..974ff7d07d8 100644
--- a/common/lib/xmodule/xmodule/tests/test_course_module.py
+++ b/common/lib/xmodule/xmodule/tests/test_course_module.py
@@ -451,7 +451,7 @@ class ProctoringProviderTestCase(unittest.TestCase):
 
         with pytest.raises(ValueError) as context_manager:
             self.proctoring_provider.from_json(provider)
-        assert context_manager.exception.args[0] ==\
+        assert context_manager.value.args[0] ==\
                [f'The selected proctoring provider, {provider},'
                 f' is not a valid provider. Please select from one of {allowed_proctoring_providers}.']
 
diff --git a/common/lib/xmodule/xmodule/tests/test_graders.py b/common/lib/xmodule/xmodule/tests/test_graders.py
index 30995b5cf1e..f8e88f81271 100644
--- a/common/lib/xmodule/xmodule/tests/test_graders.py
+++ b/common/lib/xmodule/xmodule/tests/test_graders.py
@@ -337,7 +337,7 @@ class GraderTest(unittest.TestCase):
     def test_grader_with_invalid_conf(self, invalid_conf, expected_error_message):
         with pytest.raises(ValueError) as error:
             graders.grader_from_conf([invalid_conf])
-        assert expected_error_message in text_type(error.exception)
+        assert expected_error_message in text_type(error.value)
 
 
 @ddt.ddt
-- 
GitLab