This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit ec117d6f56a249defff25a79002f4657fd5cf2eb
Author: Dave Brondsema <dbronds...@slashdotmedia.com>
AuthorDate: Tue May 7 11:56:02 2024 -0400

    update tests
---
 Allura/allura/tests/test_helpers.py | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/Allura/allura/tests/test_helpers.py 
b/Allura/allura/tests/test_helpers.py
index 7bf3a55bc..430edd7e9 100644
--- a/Allura/allura/tests/test_helpers.py
+++ b/Allura/allura/tests/test_helpers.py
@@ -476,7 +476,7 @@ class TestUrlOpen(TestCase):
     @patch('urllib.request.urlopen')
     def test_no_error(self, urlopen):
         r = h.urlopen('http://example.com')
-        self.assertEqual(r, urlopen.return_value)
+        assert r == urlopen.return_value
         urlopen.assert_called_once_with('http://example.com', timeout=None)
 
     @patch('urllib.request.urlopen')
@@ -487,8 +487,9 @@ class TestUrlOpen(TestCase):
             raise socket.timeout()
 
         urlopen.side_effect = side_effect
-        self.assertRaises(socket.timeout, h.urlopen, 'http://example.com')
-        self.assertEqual(urlopen.call_count, 4)
+        with pytest.raises(socket.timeout):
+            h.urlopen('http://example.com')
+        assert urlopen.call_count == 4
 
     @patch('urllib.request.urlopen')
     def test_socket_reset(self, urlopen):
@@ -499,8 +500,9 @@ class TestUrlOpen(TestCase):
             raise OSError(errno.ECONNRESET, 'Connection reset by peer')
 
         urlopen.side_effect = side_effect
-        self.assertRaises(socket.error, h.urlopen, 'http://example.com')
-        self.assertEqual(urlopen.call_count, 4)
+        with pytest.raises(socket.error):
+            h.urlopen('http://example.com')
+        assert urlopen.call_count == 4
 
     @patch('urllib.request.urlopen')
     def test_handled_http_error(self, urlopen):
@@ -510,8 +512,9 @@ class TestUrlOpen(TestCase):
             raise HTTPError('url', 408, 'timeout', None, io.BytesIO())
 
         urlopen.side_effect = side_effect
-        self.assertRaises(HTTPError, h.urlopen, 'http://example.com')
-        self.assertEqual(urlopen.call_count, 4)
+        with pytest.raises(HTTPError):
+            h.urlopen('http://example.com')
+        assert urlopen.call_count == 4
 
     @patch('urllib.request.urlopen')
     def test_unhandled_http_error(self, urlopen):
@@ -521,8 +524,9 @@ class TestUrlOpen(TestCase):
             raise HTTPError('url', 404, 'timeout', None, io.BytesIO())
 
         urlopen.side_effect = side_effect
-        self.assertRaises(HTTPError, h.urlopen, 'http://example.com')
-        self.assertEqual(urlopen.call_count, 1)
+        with pytest.raises(HTTPError):
+            h.urlopen('http://example.com')
+        assert urlopen.call_count == 1
 
 
 def test_absurl():

Reply via email to