8000 Fix Python 2.7 compatibility of the tests · unho/python-stdnum@27c7c74 · GitHub
[go: up one dir, main page]

Skip to content

Commit 27c7c74

Browse files
committed
Fix Python 2.7 compatibility of the tests
Fixes a9039c1
1 parent cfc80c8 commit 27c7c74

File tree

2 files changed

+39
-20
lines changed

2 files changed

+39
-20
lines changed

stdnum/cfi.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,16 @@
3535
Traceback (most recent call last):
3636
...
3737
InvalidComponent: ...
38-
>>> info('ELNUFR')['Payment status']
39-
'Fully paid'
38+
>>> import json
39+
>>> print(json.dumps(info('ELNUFR'), indent=2, sort_keys=True))
40+
{
41+
"Form": "Registered",
42+
"Ownership/transfer/sales restrictions": "Free",
43+
"Payment status": "Fully paid",
44+
"Voting right": "Non-voting",
45+
"category": "Equities",
46+
"group": "Limited partnership units"
47+
}
4048
"""
4149

4250
from stdnum import numdb

tests/test_cfi.doctest

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
2121
This file contains more detailed doctests for the stdnum.cfi module. It
2222
tries to validate a number of numbers that have been found online.
2323

24-
>>> import pprint
24+
>>> import json
2525
>>> from stdnum import cfi
2626
>>> from stdnum.exceptions import *
2727

@@ -64,23 +64,34 @@ Most characters can be replaced by an X.
6464

6565
The info function returns useful information.
6666

67-
>>> pprint.pprint(cfi.info('DTFNFR'))
68-
{'Form': 'Registered',
69-
'Guarantee or ranking': 'Senior',
70-
'Redemption/reimbursement': 'Fixed maturity',
71-
'Type of interest': 'Fixed rate',
72-
'category': 'Debt instruments',
73-
'group': 'Medium-term notes'}
74-
>>> pprint.pprint(cfi.info('IFXXXP'))
75-
{'Delivery': 'Physical', 'category': 'Spot', 'group': 'Foreign exchange'}
76-
>>> pprint.pprint(cfi.info('IFXXXX'))
77-
{'category': 'Spot', 'group': 'Foreign exchange'}
78-
>>> pprint.pprint(cfi.info('DBFNXR'))
79-
{'Form': 'Registered',
80-
'Guarantee or ranking': 'Senior',
81-
'Type of interest or cash payment': 'Fixed rate',
82-
'category': 'Debt instruments',
83-
'group': 'Bonds'}
67+
>>> print(json.dumps(cfi.info('DTFNFR'), indent=2, sort_keys=True))
68+
{
69+
"Form": "Registered",
70+
"Guarantee or ranking": "Senior",
71+
"Redemption/reimbursement": "Fixed maturity",
72+
"Type of interest": "Fixed rate",
73+
"category": "Debt instruments",
74+
"group": "Medium-term notes"
75+
}
76+
>>> print(json.dumps(cfi.info('IFXXXP'), indent=2, sort_keys=True))
77+
{
78+
"Delivery": "Physical",
79+
"category": "Spot",
80+
"group": "Foreign exchange"
81+
}
82+
>>> print(json.dumps(cfi.info('IFXXXX'), indent=2, sort_keys=True))
83+
{
84+
"category": "Spot",
85+
"group": "Foreign exchange"
86+
}
87+
>>> print(json.dumps(cfi.info('DBFNXR'), indent=2, sort_keys=True))
88+
{
89+
"Form": "Registered",
90+
"Guarantee or ranking": "Senior",
91+
"Type of interest or cash payment": "Fixed rate",
92+
"category": "Debt instruments",
93+
"group": "Bonds"
94+
}
8495

8596

8697
These should all be valid numbers.

0 commit comments

Comments
 (0)
0