Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor deprecated unittest aliases for Python 3.11 compatibility. #489

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions tests/adwords_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def testAdWordsPackerForServiceQuery(self):
query_regex = (r'SELECT (.*) WHERE Status = "ENABLED"'
r' ORDER BY Name ASC LIMIT 0,100')

self.assertRegexpMatches(self.packer.Pack(query, CURRENT_VERSION),
self.assertRegex(self.packer.Pack(query, CURRENT_VERSION),
query_regex)

def testAdWordsPackerForUnsupportedObjectType(self):
Expand Down Expand Up @@ -1354,15 +1354,15 @@ def testLoad(self):
restored_uploader = googleads.adwords.IncrementalUploadHelper.Load(
s, client=self.client)

self.assertEquals(restored_uploader._current_content_length,
self.assertEqual(restored_uploader._current_content_length,
self.incremental_uploader._current_content_length)
self.assertEquals(restored_uploader._is_last,
self.assertEqual(restored_uploader._is_last,
self.incremental_uploader._is_last)
self.assertEquals(restored_uploader._request_builder._version,
self.assertEqual(restored_uploader._request_builder._version,
self.version)
self.assertEquals(restored_uploader._upload_url,
self.assertEqual(restored_uploader._upload_url,
self.incremental_uploader._upload_url)
self.assertEquals(restored_uploader._request_builder.GetServer(),
self.assertEqual(restored_uploader._request_builder.GetServer(),
self.server)

def testUploadOperations(self):
Expand Down Expand Up @@ -2137,7 +2137,7 @@ def testCopyConstructor(self):
# The SELECT clause can show fields listed in any orders.
self.assertCountEqual(selected_fields,
[field.strip() for field in match.group(1).split(',')])
self.assertRegexpMatches(str(actual_query), awql_regex)
self.assertRegex(str(actual_query), awql_regex)

def testFailUsingCopyConstructor(self):
builder = googleads.adwords._QueryBuilder()
Expand All @@ -2157,7 +2157,7 @@ def testBuild(self):
# The SELECT clause can show fields listed in any orders.
self.assertCountEqual(selected_fields,
[field.strip() for field in match.group(1).split(',')])
self.assertRegexpMatches(str(actual_query), awql_regex)
self.assertRegex(str(actual_query), awql_regex)

def testBuild_duplicateSelectedFieldsRetainOnlyUnique(self):
awql_regex = (r'SELECT (.*) LIMIT 0,100')
Expand All @@ -2171,7 +2171,7 @@ def testBuild_duplicateSelectedFieldsRetainOnlyUnique(self):
# The SELECT clause retains only unique fields.
self.assertCountEqual(set(selected_fields),
[field.strip() for field in match.group(1).split(',')])
self.assertRegexpMatches(str(actual_query), awql_regex)
self.assertRegex(str(actual_query), awql_regex)

def testBuild_whereConditions(self):
awql_regex = (r'SELECT (.*)'
Expand All @@ -2192,7 +2192,7 @@ def testBuild_whereConditions(self):
# The SELECT clause can show fields listed in any orders.
self.assertCountEqual(selected_fields,
[field.strip() for field in match.group(1).split(',')])
self.assertRegexpMatches(str(actual_query), awql_regex)
self.assertRegex(str(actual_query), awql_regex)

def testBuild_orderByDesc(self):
awql_regex = (r'SELECT (.*)'
Expand All @@ -2209,7 +2209,7 @@ def testBuild_orderByDesc(self):
# The SELECT clause can show fields listed in any orders.
self.assertCountEqual(selected_fields,
[field.strip() for field in match.group(1).split(',')])
self.assertRegexpMatches(str(actual_query), awql_regex)
self.assertRegex(str(actual_query), awql_regex)

def testBuild_selectIsNone(self):
with self.assertRaises(ValueError):
Expand Down Expand Up @@ -2244,7 +2244,7 @@ def testNextPage(self):
# Do next page and check if the LIMIT clause is modified correctly.
awql_regex = (r'SELECT (.*) LIMIT 100,100')
actual_query.NextPage()
self.assertRegexpMatches(str(actual_query), awql_regex)
self.assertRegex(str(actual_query), awql_regex)

def testNextPageForDataService(self):
selected_fields = ['Id', 'Name']
Expand All @@ -2265,7 +2265,7 @@ def testNextPageForDataService(self):
# points of the page.
awql_regex = (r'SELECT (.*) LIMIT 4,2')
actual_query.NextPage(page)
self.assertRegexpMatches(str(actual_query), awql_regex)
self.assertRegex(str(actual_query), awql_regex)

def testNextPageFail(self):
actual_query = googleads.adwords.ServiceQuery('SELECT Id, Name', None, 100)
Expand All @@ -2280,19 +2280,19 @@ def testHasNext(self):
.Limit(0, 1)
.Build())
awql_regex = (r'SELECT (.*) LIMIT 0,1')
self.assertRegexpMatches(str(actual_query), awql_regex)
self.assertRegex(str(actual_query), awql_regex)

page = {'totalNumEntries': 3}

self.assertTrue(actual_query.HasNext(page))
awql_regex = (r'SELECT (.*) LIMIT 1,1')
actual_query.NextPage()
self.assertRegexpMatches(str(actual_query), awql_regex)
self.assertRegex(str(actual_query), awql_regex)

self.assertTrue(actual_query.HasNext(page))
awql_regex = (r'SELECT (.*) LIMIT 2,1')
actual_query.NextPage()
self.assertRegexpMatches(str(actual_query), awql_regex)
self.assertRegex(str(actual_query), awql_regex)

self.assertFalse(actual_query.HasNext(page))

Expand Down