From 1e9c2f7a3cc2ee78caa79d0602f3afe2030dcf5e Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Tue, 3 Sep 2024 07:54:12 +0000 Subject: [PATCH] Fix unit test for Python 3.13 As of Python 3.13, tabs in docstrings are expanded to spaces, thereby breaking one of the unit tests. This commit fixes the unit test. Note that neither the problem nor this fix affect the main pysmi code. --- tests/test_moduleidentity_smiv2_pysnmp.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_moduleidentity_smiv2_pysnmp.py b/tests/test_moduleidentity_smiv2_pysnmp.py index 8c181a8..eeee0f5 100644 --- a/tests/test_moduleidentity_smiv2_pysnmp.py +++ b/tests/test_moduleidentity_smiv2_pysnmp.py @@ -157,7 +157,7 @@ class ModuleIdentityTextTestCase(unittest.TestCase): organization" CONTACT-INFO "WG-email:\\n agentx@dorothy.bmc.com\\" DESCRIPTION " - A\tdescription with\\n + Adescription with\\n various characters: 0~`!@#$%^&*()-_=+[]{}\\|;:'<>,.?/ and a very long line that must not be wrapped despite exceeding the threshold of default word wrap filters. @@ -170,7 +170,9 @@ class ModuleIdentityTextTestCase(unittest.TestCase): """ def setUp(self): - docstring = textwrap.dedent(self.__class__.__doc__) + # As of Python 3.13, tabs are expanded in docstrings, so we have to use + # a placeholder and replace it with real tab here. + docstring = textwrap.dedent(self.__class__.__doc__.replace("", "\t")) ast = parserFactory()().parse(docstring)[0] mibInfo, symtable = SymtableCodeGen().genCode(ast, {}, genTexts=True) self.mibInfo, pycode = PySnmpCodeGen().genCode(