Merge pull request #548 from hydrosquall/cameron.yick/replace-deprecated-testing-method

[testing] Replace deprecated assertRaisesRegexp with assertRaisesRegex
This commit is contained in:
Cameron Yick
2020-12-12 21:35:04 -05:00
committed by GitHub
2 changed files with 17 additions and 3 deletions

View File

@@ -13,7 +13,7 @@ History
* Feature: Add option to request data in csv format in get_dataframe method potentially boosting speed up to 4-5x. (#523)
* Minor: bumped library dependencies, in particular cryptography
* Development: Dropped official support for Python 3.5, replaced with 3.7
* Development: Publish library with Github Actions instead of Travis (#546
* Development: Publish library with Github Actions instead of Travis (#546)
0.12.0 (2019-10-20)
--------------------

View File

@@ -34,7 +34,14 @@ class TestRestClient(TestCase):
# Test 404 error
def test_invalid_url(self):
with self.assertRaisesRegexp(RestClientError, "404"),\
# Suppress deprecation warning in python 3
if hasattr(self, 'assertRaisesRegex'):
assertFunc = self.assertRaisesRegex
else:
assertFunc = self.assertRaisesRegexp
with assertFunc(RestClientError, "404"),\
vcr.use_cassette('tests/fixtures/invalid_url.yaml'):
# Should return 404 error
self._client._request('GET', "bing_is_great")
@@ -66,7 +73,14 @@ class TestRestClientWithSession(TestCase):
# Test 404 error
def test_invalid_url(self):
with self.assertRaisesRegexp(RestClientError, "404"),\
# Suppress deprecation warning in python 3
if hasattr(self, 'assertRaisesRegex'):
assertFunc = self.assertRaisesRegex
else:
assertFunc = self.assertRaisesRegexp
with assertFunc(RestClientError, "404"),\
vcr.use_cassette('tests/fixtures/invalid_url.yaml'):
# Should return 404 error
self._client._request('GET', "bing_is_great")