Mercurial > p > roundup > code
diff test/test_anypy.py @ 6532:e4db9d0b85c7
test for issue2551170 process python 2 long under python3
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 16 Nov 2021 23:34:37 -0500 |
| parents | |
| children | c65e0a725c88 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/test_anypy.py Tue Nov 16 23:34:37 2021 -0500 @@ -0,0 +1,43 @@ +"""Random tests for anypy modules""" + + +import unittest +from roundup.anypy.strings import repr_export, eval_import + +import sys +_py3 = sys.version_info[0] > 2 + +class StringsTest(unittest.TestCase): + + def test_import_params(self): + """ issue2551170 - handle long int in history/journal + params tuple + """ + # python2 export with id as number + val = eval_import("('issue', 2345L, 'status')") + self.assertSequenceEqual(val, ('issue', 2345, 'status')) + + # python3 export with id as number + val = eval_import("('issue', 2345, 'status')") + self.assertSequenceEqual(val, ('issue', 2345, 'status')) + + # python2 or python3 export with id as string + val = eval_import("('issue', '2345', 'status')") + self.assertSequenceEqual(val, ('issue', '2345', 'status')) + + def test_export_params(self): + """ issue2551170 - handle long int in history/journal + params tuple + """ + # python2 export with id as number + if _py3: + val = repr_export(('issue', 2345, 'status')) + self.assertEqual(val, "('issue', 2345, 'status')") + else: + val = repr_export(('issue', long(2345), 'status')) + self.assertEqual(val, "('issue', 2345L, 'status')") + + # python2 or python3 export with id as string + val = repr_export(('issue', '2345', 'status')) + self.assertEqual(val, "('issue', '2345', 'status')") +
