Skip to content

Commit 88ffa9a

Browse files
committed
Refactor deprecated unittest aliases for Python 3.11 compatibility.
1 parent ad5ddc9 commit 88ffa9a

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

test/cmdline_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def test_cmd_line_params_are_available_for_execution_summary(self):
362362
print(stdout)
363363
print(stderr)
364364

365-
self.assertNotEquals(returncode, 1)
365+
self.assertNotEqual(returncode, 1)
366366
self.assertFalse(b'required_test_param' in stderr)
367367

368368

test/contrib/external_daily_snapshot_test.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ class ExternalDailySnapshotTest(unittest.TestCase):
3232
def test_latest(self):
3333
MockTarget('data-xyz-zebra-Congo-2012-01-01').open('w').close()
3434
d = DataDump.latest(date=datetime.date(2012, 1, 10), param='xyz')
35-
self.assertEquals(d.date, datetime.date(2012, 1, 1))
35+
self.assertEqual(d.date, datetime.date(2012, 1, 1))
3636

3737
def test_latest_not_exists(self):
3838
MockTarget('data-abc-zebra-Congo-2012-01-01').open('w').close()
3939
d = DataDump.latest(date=datetime.date(2012, 1, 11), param='abc', lookback=5)
40-
self.assertEquals(d.date, datetime.date(2012, 1, 7))
40+
self.assertEqual(d.date, datetime.date(2012, 1, 7))
4141

4242
def test_deterministic(self):
4343
MockTarget('data-pqr-zebra-Congo-2012-01-01').open('w').close()
4444
d = DataDump.latest(date=datetime.date(2012, 1, 10), param='pqr', a='zebra', aa='Congo')
45-
self.assertEquals(d.date, datetime.date(2012, 1, 1))
45+
self.assertEqual(d.date, datetime.date(2012, 1, 1))
4646

4747
MockTarget('data-pqr-zebra-Congo-2012-01-05').open('w').close()
4848
d = DataDump.latest(date=datetime.date(2012, 1, 10), param='pqr', aa='Congo', a='zebra')
49-
self.assertEquals(d.date, datetime.date(2012, 1, 1)) # Should still be the same
49+
self.assertEqual(d.date, datetime.date(2012, 1, 1)) # Should still be the same

test/contrib/hdfs_test.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def test_glob_exists(self):
168168
self.assertFalse(files.glob_exists(3))
169169
self.assertFalse(files.glob_exists(1))
170170

171-
def assertRegexpMatches(self, text, expected_regexp, msg=None):
171+
def assertRegex(self, text, expected_regexp, msg=None):
172172
"""Python 2.7 backport."""
173173
if isinstance(expected_regexp, str):
174174
expected_regexp = re.compile(expected_regexp)
@@ -201,21 +201,21 @@ def test_tmppath_not_configured(self):
201201
res9 = hdfs.tmppath(path9, include_unix_username=False)
202202

203203
# Then: I should get correct results relative to Luigi temporary directory
204-
self.assertRegexpMatches(res1, "^/tmp/dir1/dir2/file-luigitemp-\\d+")
204+
self.assertRegex(res1, "^/tmp/dir1/dir2/file-luigitemp-\\d+")
205205
# it would be better to see hdfs:///path instead of hdfs:/path, but single slash also works well
206-
self.assertRegexpMatches(res2, "^hdfs:/tmp/dir1/dir2/file-luigitemp-\\d+")
207-
self.assertRegexpMatches(res3, "^hdfs://somehost/tmp/dir1/dir2/file-luigitemp-\\d+")
208-
self.assertRegexpMatches(res4, "^file:///tmp/dir1/dir2/file-luigitemp-\\d+")
209-
self.assertRegexpMatches(res5, "^/tmp/dir/file-luigitemp-\\d+")
206+
self.assertRegex(res2, "^hdfs:/tmp/dir1/dir2/file-luigitemp-\\d+")
207+
self.assertRegex(res3, "^hdfs://somehost/tmp/dir1/dir2/file-luigitemp-\\d+")
208+
self.assertRegex(res4, "^file:///tmp/dir1/dir2/file-luigitemp-\\d+")
209+
self.assertRegex(res5, "^/tmp/dir/file-luigitemp-\\d+")
210210
# known issue with duplicated "tmp" if schema is present
211-
self.assertRegexpMatches(res6, "^file:///tmp/tmp/dir/file-luigitemp-\\d+")
211+
self.assertRegex(res6, "^file:///tmp/tmp/dir/file-luigitemp-\\d+")
212212
# known issue with duplicated "tmp" if schema is present
213-
self.assertRegexpMatches(res7, "^hdfs://somehost/tmp/tmp/dir/file-luigitemp-\\d+")
214-
self.assertRegexpMatches(res8, "^/tmp/luigitemp-\\d+")
215-
self.assertRegexpMatches(res9, "/tmp/tmpdir/file")
213+
self.assertRegex(res7, "^hdfs://somehost/tmp/tmp/dir/file-luigitemp-\\d+")
214+
self.assertRegex(res8, "^/tmp/luigitemp-\\d+")
215+
self.assertRegex(res9, "/tmp/tmpdir/file")
216216

217217
def test_tmppath_username(self):
218-
self.assertRegexpMatches(hdfs.tmppath('/path/to/stuff', include_unix_username=True),
218+
self.assertRegex(hdfs.tmppath('/path/to/stuff', include_unix_username=True),
219219
"^/tmp/[a-z0-9_]+/path/to/stuff-luigitemp-\\d+")
220220

221221
def test_pickle(self):

test/contrib/postgres_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,11 @@ def test_bulk_complete(self, mock_connect):
132132

133133
def test_override_port(self):
134134
output = DummyPostgresQueryWithPort(date=datetime.datetime(1991, 3, 24)).output()
135-
self.assertEquals(output.port, 1234)
135+
self.assertEqual(output.port, 1234)
136136

137137
def test_port_encoded_in_host(self):
138138
output = DummyPostgresQueryWithPortEncodedInHost(date=datetime.datetime(1991, 3, 24)).output()
139-
self.assertEquals(output.port, '1234')
139+
self.assertEqual(output.port, '1234')
140140

141141

142142
@pytest.mark.postgres

test/contrib/s3_test.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def test_get(self):
342342
s3_client.get('s3://mybucket/putMe', tmp_file_path)
343343
with open(tmp_file_path, 'r') as f:
344344
content = f.read()
345-
self.assertEquals(content, self.tempFileContents.decode("utf-8"))
345+
self.assertEqual(content, self.tempFileContents.decode("utf-8"))
346346
tmp_file.close()
347347

348348
def test_get_as_bytes(self):
@@ -352,7 +352,7 @@ def test_get_as_bytes(self):
352352

353353
contents = s3_client.get_as_bytes('s3://mybucket/putMe')
354354

355-
self.assertEquals(contents, self.tempFileContents)
355+
self.assertEqual(contents, self.tempFileContents)
356356

357357
def test_get_as_string(self):
358358
create_bucket()
@@ -361,7 +361,7 @@ def test_get_as_string(self):
361361

362362
contents = s3_client.get_as_string('s3://mybucket/putMe2')
363363

364-
self.assertEquals(contents, self.tempFileContents.decode('utf-8'))
364+
self.assertEqual(contents, self.tempFileContents.decode('utf-8'))
365365

366366
def test_get_as_string_latin1(self):
367367
create_bucket()
@@ -370,7 +370,7 @@ def test_get_as_string_latin1(self):
370370

371371
contents = s3_client.get_as_string('s3://mybucket/putMe3', encoding='ISO-8859-1')
372372

373-
self.assertEquals(contents, self.tempFileContents.decode('ISO-8859-1'))
373+
self.assertEqual(contents, self.tempFileContents.decode('ISO-8859-1'))
374374

375375
def test_get_key(self):
376376
create_bucket()

test/interface_test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ class CoreConfigTest(LuigiTestCase):
204204

205205
@with_config({})
206206
def test_parallel_scheduling_processes_default(self):
207-
self.assertEquals(0, core().parallel_scheduling_processes)
207+
self.assertEqual(0, core().parallel_scheduling_processes)
208208

209209
@with_config({'core': {'parallel-scheduling-processes': '1234'}})
210210
def test_parallel_scheduling_processes(self):
211211
from luigi.interface import core
212-
self.assertEquals(1234, core().parallel_scheduling_processes)
212+
self.assertEqual(1234, core().parallel_scheduling_processes)

0 commit comments

Comments
 (0)