Skip to content

Commit bbab36d

Browse files
committed
feat: Make iData value optional (dft to empty str)
1 parent 6055cf3 commit bbab36d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/itoolkit/itoolkit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,10 @@ class iData (iBase): # noqa N801
622622
http://yips.idevcloud.com/wiki/index.php/XMLService/DataTypes
623623
624624
.. versionchanged:: 1.6.3
625-
`ival` now supports non-string parameters.
625+
`ival` is now optional and supports non-string parameters.
626626
"""
627627

628-
def __init__(self, ikey, itype, ival, iopt={}):
628+
def __init__(self, ikey, itype, ival="", iopt={}):
629629
opts = {
630630
'i': ikey,
631631
'k': 'data',

tests/test_unit_data.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,15 @@ def test_data_and_options():
4545
for k, v in opts.items():
4646
assert(element.attrib[k] == str(v))
4747
assert(element.text == value)
48+
49+
50+
def test_data_default_value():
51+
key = 'madsn'
52+
datatype = '10a'
53+
54+
element = ET.fromstring(iData(key, datatype).xml_in())
55+
56+
assert(element.tag == 'data')
57+
assert(element.attrib['var'] == key)
58+
assert(element.attrib['type'] == datatype)
59+
assert(element.text is None)

0 commit comments

Comments
 (0)