Skip to content

Commit 33e24c5

Browse files
committed
test for issue2551170 process python 2 long under python3
1 parent dda1c60 commit 33e24c5

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

test/test_anypy.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+

0 commit comments

Comments
 (0)