diff --git a/tests/unit/json2code_test.py b/tests/unit/json2code_test.py index 46c912bb76..05560b0bb4 100755 --- a/tests/unit/json2code_test.py +++ b/tests/unit/json2code_test.py @@ -27,6 +27,7 @@ import unittest import urllib.request import urllib.parse +from http import HTTPStatus class TestJson2Code(unittest.TestCase): @@ -79,11 +80,11 @@ def test_missing_path_param(self): with self.assertRaises(urllib.error.HTTPError) as e: with urllib.request.urlopen(url): pass - ex = e.exception - self.assertEqual(ex.code, 404) - response = json.loads(ex.read().decode('utf-8')) - self.assertEqual(response['message'], 'Not found') - self.assertEqual(response['code'], 404) + ex = e.exception + self.assertEqual(ex.code, HTTPStatus.NOT_FOUND) + response = json.loads(ex.read().decode('utf-8')) + self.assertEqual(response['message'], 'Not found') + self.assertEqual(response['code'], HTTPStatus.NOT_FOUND) if __name__ == '__main__':