tools: binman: fix deprecated Python unittest methods
PATCH 1/3 tools: binman: fix deprecated Python unittest methods
The methods unittest.assertEquals() and unittest.assertRegexpMatches() are marked deprecated[1].
In Python 3.12 these aliases have been removed, so do a sed to replace them with their new names.
[1] https://docs.python.org/3.11/library/unittest.html#deprecated-aliases
--- tools/binman/entry_test.py | 6 +-- tools/binman/fdt_test.py | 48 ++++++++++++------------ tools/binman/ftest.py | 42 ++++++++++----------- tools/buildman/func_test.py | 74 ++++++++++++++++++------------------- tools/buildman/test.py | 2 +- 5 files changed, 86 insertions(+), 86 deletions(-)
tools/binman/entry_test.py +3 -3
@@ -103,7 +103,7 @@ class TestEntry(unittest.TestCase): ent = entry.Entry.Create(None, self.GetNode(), 'missing', missing_etype=True) self.assertTrue(isinstance(ent, Entry_blob)) - self.assertEquals('missing', ent.etype) + self.assertEqual('missing', ent.etype) def testDecompressData(self): """Test the DecompressData() method of the base class"""
@@ -111,8 +111,8 @@ class TestEntry(unittest.TestCase): base.compress = 'lz4' bintools = {} base.comp_bintool = base.AddBintool(bintools, '_testing') - self.assertEquals(tools.get_bytes(0, 1024), base.CompressData(b'abc')) - self.assertEquals(tools.get_bytes(0, 1024), base.DecompressData(b'abc')) + self.assertEqual(tools.get_bytes(0, 1024), base.CompressData(b'abc')) + self.assertEqual(tools.get_bytes(0, 1024), base.DecompressData(b'abc')) def testLookupOffset(self): """Test the lookup_offset() method of the base class"""
tools/binman/fdt_test.py +24 -24
67 lines not on this page · raw message
tools/binman/ftest.py +21 -21
136 lines not on this page · raw message
tools/buildman/func_test.py +37 -37
159 lines not on this page · raw message
tools/buildman/test.py +1 -1
@@ -584,7 +584,7 @@ class TestBuild(unittest.TestCase): if use_network: with test_util.capture_sys_output() as (stdout, stderr): url = self.toolchains.LocateArchUrl('arm') - self.assertRegexpMatches(url, 'https://www.kernel.org/pub/tools/' + self.assertRegex(url, 'https://www.kernel.org/pub/tools/' 'crosstool/files/bin/x86_64/.*/' 'x86_64-gcc-.*-nolibc[-_]arm-.*linux-gnueabi.tar.xz')
Signature · 1 line
2.45.1
PATCH 2/3 tools: binman: fix deprecated Python ConfigParser methods
The method ConfigParser.readfp() is marked deprecated[1].
In Python 3.12 this method have been removed, so replace it with ConfigParser.read_file().
[1] https://docs.python.org/3.11/library/configparser.html#configparser.ConfigParser.readfp
--- tools/buildman/bsettings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/buildman/bsettings.py +1 -1
@@ -29,7 +29,7 @@ def setup(fname=''): settings.read(config_fname) def add_file(data): - settings.readfp(io.StringIO(data)) + settings.read_file(io.StringIO(data)) def get_items(section): """Get the items from a section of the config.
Signature · 1 line
2.45.1
Re: [PATCH 2/3] tools: binman: fix deprecated Python ConfigParser methods
Hi Brandon,
Quoted 6 lines · Brandon Maier
The method
ConfigParser.readfp()is marked deprecated[1].In Python 3.12 this method have been removed, so replace it with
ConfigParser.read_file().
Quoted 7 lines
[1] https://docs.python.org/3.11/library/configparser.html#configparser.ConfigParser.readfp
Signed-off-by Brandon Maier <[email protected]>CC Simon Glass <[email protected]>--- tools/buildman/bsettings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Does this still work in earlier Pythons?
Regards,
Simon
RE: [External] Re: [PATCH 2/3] tools: binman: fix deprecated Python ConfigParser methods
Hi Simon,
Quoted 26 lines
-----Original Message-----
From: Simon Glass <[email protected]>
Sent: Tuesday, June 4, 2024 9:14 PM
To: Maier, Brandon L Collins <[email protected]>
Cc: [email protected]
Subject: [External] Re: [PATCH 2/3] tools: binman: fix deprecated Python ConfigParser methodsHi Brandon,
Quoted 7 lines · Brandon Maier
The method
ConfigParser.readfp()is marked deprecated[1].In Python 3.12 this method have been removed, so replace it with
ConfigParser.read_file().[1]
https://docs.python.org/3.11/library/configparser.html#configparser.ConfigParser.read_file
Quoted 5 lines
Signed-off-by Brandon Maier <[email protected]>CC Simon Glass <[email protected]>--- tools/buildman/bsettings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 3 lines
Reviewed-by Simon Glass <[email protected]>Does this still work in earlier Pythons?
The Python docs say ConfigParser.read_file() was added in Python 3.2.
The tools/buildman/pyproject.toml says requires-python = ">=3.7" so I assume this is fine.
Quoted 3 lines
Regards,
Simon
Re: RE: [External] Re: [PATCH 2/3] tools: binman: fix deprecated Python ConfigParser methods
Hi Simon,
Quoted 26 lines
-----Original Message-----
From: Simon Glass <[email protected]>
Sent: Tuesday, June 4, 2024 9:14 PM
To: Maier, Brandon L Collins <[email protected]>
Cc: [email protected]
Subject: [External] Re: [PATCH 2/3] tools: binman: fix deprecated Python ConfigParser methodsHi Brandon,
Quoted 7 lines · Brandon Maier
The method
ConfigParser.readfp()is marked deprecated[1].In Python 3.12 this method have been removed, so replace it with
ConfigParser.read_file().[1]
https://docs.python.org/3.11/library/configparser.html#configparser.ConfigParser.read_file
Quoted 5 lines
Signed-off-by Brandon Maier <[email protected]>CC Simon Glass <[email protected]>--- tools/buildman/bsettings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 3 lines
Reviewed-by Simon Glass <[email protected]>Does this still work in earlier Pythons?
The Python docs say ConfigParser.read_file() was added in Python 3.2. The tools/buildman/pyproject.toml says requires-python = ">=3.7" so I assume this is fine.
Quoted 3 lines
Regards,
Simon
Applied to u-boot-dm, thanks!
PATCH 3/3 tools: patman: fix deprecated Python ConfigParser methods
In reply to Brandon MaierThe method ConfigParser.readfp() is marked deprecated[1].
In Python 3.12 this method have been removed, so replace it with ConfigParser.read_file().
[1] https://docs.python.org/3.11/library/configparser.html#configparser.ConfigParser.readfp
--- tools/patman/settings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/patman/settings.py +4 -4
@@ -59,25 +59,25 @@ class _ProjectConfigParser(ConfigParser.ConfigParser): # Check to make sure that bogus project gets general alias. >>> config = _ProjectConfigParser("zzz") - >>> config.readfp(StringIO(sample_config)) + >>> config.read_file(StringIO(sample_config)) >>> str(config.get("alias", "enemies")) 'Evil <[email protected]>' # Check to make sure that alias gets overridden by project. >>> config = _ProjectConfigParser("sm") - >>> config.readfp(StringIO(sample_config)) + >>> config.read_file(StringIO(sample_config)) >>> str(config.get("alias", "enemies")) 'Green G. <[email protected]>' # Check to make sure that settings get merged with project. >>> config = _ProjectConfigParser("linux") - >>> config.readfp(StringIO(sample_config)) + >>> config.read_file(StringIO(sample_config)) >>> sorted((str(a), str(b)) for (a, b) in config.items("settings")) [('am_hero', 'True'), ('check_patch_use_tree', 'True'), ('process_tags', 'False')] # Check to make sure that settings works with unknown project. >>> config = _ProjectConfigParser("unknown") - >>> config.readfp(StringIO(sample_config)) + >>> config.read_file(StringIO(sample_config)) >>> sorted((str(a), str(b)) for (a, b) in config.items("settings")) [('am_hero', 'True')] """
Signature · 1 line
2.45.1
Re: [PATCH 3/3] tools: patman: fix deprecated Python ConfigParser methods
Quoted 6 lines · Brandon Maier
The method
ConfigParser.readfp()is marked deprecated[1].In Python 3.12 this method have been removed, so replace it with
ConfigParser.read_file().
Quoted 7 lines
[1] https://docs.python.org/3.11/library/configparser.html#configparser.ConfigParser.readfp
Signed-off-by Brandon Maier <[email protected]>CC Simon Glass <[email protected]>--- tools/patman/settings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Simon Glass
Reviewed-byRe: [PATCH 3/3] tools: patman: fix deprecated Python ConfigParser methods
Quoted 6 lines · Brandon Maier
The method
ConfigParser.readfp()is marked deprecated[1].In Python 3.12 this method have been removed, so replace it with
ConfigParser.read_file().
Quoted 7 lines
[1] https://docs.python.org/3.11/library/configparser.html#configparser.ConfigParser.readfp
Signed-off-by Brandon Maier <[email protected]>CC Simon Glass <[email protected]>--- tools/patman/settings.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Applied to u-boot-dm, thanks!
Quoted 12 lines · Brandon Maier
The methods
unittest.assertEquals()andunittest.assertRegexpMatches()are marked deprecated[1].In Python 3.12 these aliases have been removed, so do a sed to replace them with their new names.
[1] https://docs.python.org/3.11/library/unittest.html#deprecated-aliases
Signed-off-by Brandon Maier <[email protected]>CC Simon Glass <[email protected]>CC Alper Nebi Yasak <[email protected]>
Quoted 7 lines
--- tools/binman/entry_test.py | 6 +-- tools/binman/fdt_test.py | 48 ++++++++++++------------ tools/binman/ftest.py | 42 ++++++++++----------- tools/buildman/func_test.py | 74 ++++++++++++++++++------------------- tools/buildman/test.py | 2 +- 5 files changed, 86 insertions(+), 86 deletions(-)
Simon Glass
Reviewed-byQuoted 12 lines · Brandon Maier
The methods
unittest.assertEquals()andunittest.assertRegexpMatches()are marked deprecated[1].In Python 3.12 these aliases have been removed, so do a sed to replace them with their new names.
[1] https://docs.python.org/3.11/library/unittest.html#deprecated-aliases
Signed-off-by Brandon Maier <[email protected]>CC Simon Glass <[email protected]>CC Alper Nebi Yasak <[email protected]>
Quoted 7 lines
--- tools/binman/entry_test.py | 6 +-- tools/binman/fdt_test.py | 48 ++++++++++++------------ tools/binman/ftest.py | 42 ++++++++++----------- tools/buildman/func_test.py | 74 ++++++++++++++++++------------------- tools/buildman/test.py | 2 +- 5 files changed, 86 insertions(+), 86 deletions(-)
Applied to u-boot-dm, thanks!