Skip to content

Commit

Permalink
Replace deprecated unittest aliases for Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
thesamesam committed May 29, 2023
1 parent fb46c6e commit d82ec5b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def cookie_app(environ, start_response):
('Set-Cookie', 'foo=bar;baz'),
])
else:
self.assertEquals(dict(req.cookies),
self.assertEqual(dict(req.cookies),
{'spam': 'eggs', 'foo': 'bar'})
self.assertIn('foo=bar', environ['HTTP_COOKIE'])
self.assertIn('spam=eggs', environ['HTTP_COOKIE'])
Expand Down Expand Up @@ -258,7 +258,7 @@ def cookie_app(environ, start_response):
('Set-Cookie', 'foo=bar;baz; secure'),
])
else:
self.assertEquals(dict(req.cookies),
self.assertEqual(dict(req.cookies),
{'spam': 'eggs', 'foo': 'bar'})
self.assertIn('foo=bar', environ['HTTP_COOKIE'])
self.assertIn('spam=eggs', environ['HTTP_COOKIE'])
Expand Down
6 changes: 3 additions & 3 deletions tests/test_authorisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_basic_authorization(self):
app.authorization = authorization

self.assertIn('HTTP_AUTHORIZATION', app.extra_environ)
self.assertEquals(app.authorization, authorization)
self.assertEqual(app.authorization, authorization)

resp = app.get('/')
resp.mustcontain('HTTP_AUTHORIZATION: Basic Z2F3ZWw6cGFzc3dk')
Expand All @@ -26,7 +26,7 @@ def test_basic_authorization(self):
authtype, value = header.split(' ')
auth = (authtype,
b64decode(to_bytes(value)).decode('latin1').split(':'))
self.assertEquals(authorization, auth)
self.assertEqual(authorization, auth)

app.authorization = None
self.assertNotIn('HTTP_AUTHORIZATION', app.extra_environ)
Expand All @@ -37,7 +37,7 @@ def test_bearer_authorization(self):
app.authorization = authorization

self.assertIn('HTTP_AUTHORIZATION', app.extra_environ)
self.assertEquals(app.authorization, authorization)
self.assertEqual(app.authorization, authorization)

resp = app.get('/')
resp.mustcontain('HTTP_AUTHORIZATION: Bearer 2588409761fcfa3e378bff4fb766e2e2')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ def test_upload_invalid_content(self):
single_form.submit("button")
except ValueError:
e = sys.exc_info()[1]
self.assertEquals(
self.assertEqual(
str(e),
u('File content must be %s not %s' % (bytes, int))
)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ class TestMiddleware(unittest.TestCase):
@unittest.skipIf(sys.flags.optimize > 0, "skip assert tests if optimize is enabled")
def test_lint_too_few_args(self):
linter = middleware(application)
with self.assertRaisesRegexp(AssertionError, "Two arguments required"):
with self.assertRaisesRegex(AssertionError, "Two arguments required"):
linter()
with self.assertRaisesRegexp(AssertionError, "Two arguments required"):
with self.assertRaisesRegex(AssertionError, "Two arguments required"):
linter({})

@unittest.skipIf(sys.flags.optimize > 0, "skip assert tests if optimize is enabled")
def test_lint_no_keyword_args(self):
linter = middleware(application)
with self.assertRaisesRegexp(AssertionError, "No keyword arguments "
with self.assertRaisesRegex(AssertionError, "No keyword arguments "
"allowed"):
linter({}, 'foo', baz='baz')

Expand All @@ -82,7 +82,7 @@ def test_lint_no_keyword_args(self):
def test_lint_iterator_returned(self):
linter = middleware(lambda x, y: None) # None is not an iterator
msg = "The application must return an iterator, if only an empty list"
with self.assertRaisesRegexp(AssertionError, msg):
with self.assertRaisesRegex(AssertionError, msg):
linter({'wsgi.input': 'foo', 'wsgi.errors': 'foo'}, 'foo')


Expand All @@ -109,13 +109,13 @@ def test_close(self):
def test_iter(self):
data = to_bytes("A line\nAnother line\nA final line\n")
input_wrapper = InputWrapper(BytesIO(data))
self.assertEquals(to_bytes("").join(input_wrapper), data, '')
self.assertEqual(to_bytes("").join(input_wrapper), data, '')

def test_seek(self):
data = to_bytes("A line\nAnother line\nA final line\n")
input_wrapper = InputWrapper(BytesIO(data))
input_wrapper.seek(0)
self.assertEquals(to_bytes("").join(input_wrapper), data, '')
self.assertEqual(to_bytes("").join(input_wrapper), data, '')


class TestMiddleware2(unittest.TestCase):
Expand Down

0 comments on commit d82ec5b

Please sign in to comment.