Skip to content

Commit

Permalink
common: tests: use assertEqual for python-3.12 compatibility
Browse files Browse the repository at this point in the history
On recent systems with python-3.12, the unit tests fail with a
syntax error:
======================================================================
ERROR: test_get_metadata (repo_resource.test_in.TestIn.test_get_metadata)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/repo_resource/test_in.py", line 85, in test_get_metadata
    self.assertEquals(result['metadata'][0]['name'], expected_project)
    ^^^^^^^^^^^^^^^^^
AttributeError: 'TestIn' object has no attribute 'assertEquals'. Did you mean: 'assertEqual'?

Fix it by using assertEqual instead of assertEquals.

Signed-off-by: Mattijs Korpershoek <[email protected]>
  • Loading branch information
makohoek committed Feb 9, 2024
1 parent 5237dbb commit 53e3e18
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions repo_resource/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def test_ssh_private_key_without_project_access(self):
with self.assertRaises(SystemExit):
versions = check.check(instream)

self.assertEquals(len(versions), 0)
self.assertEqual(len(versions), 0)

def test_ssh_private_key_without_manifest_access(self):
data = self.demo_ssh_manifests_source
Expand Down Expand Up @@ -306,7 +306,7 @@ def test_ssh_private_key_without_manifest_access(self):
with self.assertRaises(SystemExit):
versions = check.check(instream)

self.assertEquals(len(versions), 0)
self.assertEqual(len(versions), 0)

# test that we can specify an amount of jobs
# This is a little flaky because it depends on network
Expand Down
8 changes: 4 additions & 4 deletions repo_resource/test_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_valid_in(self):
instream = StringIO(json.dumps(data))
fetched_version = in_.in_(instream, str(common.CACHEDIR))

self.assertEquals(fetched_version['version'], data['version'])
self.assertEqual(fetched_version['version'], data['version'])

def test_get_metadata(self):
data = self.demo_manifests_source
Expand All @@ -82,8 +82,8 @@ def test_get_metadata(self):
expected_project = 'device/generic/common'
expected_revision = '033d50e2298811d81de7db8cdea63e349a96c9ba'

self.assertEquals(result['metadata'][0]['name'], expected_project)
self.assertEquals(result['metadata'][0]['value'], expected_revision)
self.assertEqual(result['metadata'][0]['name'], expected_project)
self.assertEqual(result['metadata'][0]['value'], expected_revision)

@unittest.skipUnless(
Path('development/ssh/test_key').exists(), "requires ssh test key")
Expand Down Expand Up @@ -115,4 +115,4 @@ def test_manifest_is_saved(self):
common.CACHEDIR / '.repo_manifest.xml')
expected_manifest_version = common.Version(data['version']['version'])

self.assertEquals(saved_manifest_version, expected_manifest_version)
self.assertEqual(saved_manifest_version, expected_manifest_version)

0 comments on commit 53e3e18

Please sign in to comment.