Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 6531:82f870433b18 | 6532:e4db9d0b85c7 |
|---|---|
| 1 """Random tests for anypy modules""" | |
| 2 | |
| 3 | |
| 4 import unittest | |
| 5 from roundup.anypy.strings import repr_export, eval_import | |
| 6 | |
| 7 import sys | |
| 8 _py3 = sys.version_info[0] > 2 | |
| 9 | |
| 10 class StringsTest(unittest.TestCase): | |
| 11 | |
| 12 def test_import_params(self): | |
| 13 """ issue2551170 - handle long int in history/journal | |
| 14 params tuple | |
| 15 """ | |
| 16 # python2 export with id as number | |
| 17 val = eval_import("('issue', 2345L, 'status')") | |
| 18 self.assertSequenceEqual(val, ('issue', 2345, 'status')) | |
| 19 | |
| 20 # python3 export with id as number | |
| 21 val = eval_import("('issue', 2345, 'status')") | |
| 22 self.assertSequenceEqual(val, ('issue', 2345, 'status')) | |
| 23 | |
| 24 # python2 or python3 export with id as string | |
| 25 val = eval_import("('issue', '2345', 'status')") | |
| 26 self.assertSequenceEqual(val, ('issue', '2345', 'status')) | |
| 27 | |
| 28 def test_export_params(self): | |
| 29 """ issue2551170 - handle long int in history/journal | |
| 30 params tuple | |
| 31 """ | |
| 32 # python2 export with id as number | |
| 33 if _py3: | |
| 34 val = repr_export(('issue', 2345, 'status')) | |
| 35 self.assertEqual(val, "('issue', 2345, 'status')") | |
| 36 else: | |
| 37 val = repr_export(('issue', long(2345), 'status')) | |
| 38 self.assertEqual(val, "('issue', 2345L, 'status')") | |
| 39 | |
| 40 # python2 or python3 export with id as string | |
| 41 val = repr_export(('issue', '2345', 'status')) | |
| 42 self.assertEqual(val, "('issue', '2345', 'status')") | |
| 43 |
