diff --git a/helper/set-value b/helper/set-value index 00cf5238..24a4bba9 100755 --- a/helper/set-value +++ b/helper/set-value @@ -71,7 +71,14 @@ sub set_value { $value = "\"$value\""; } - $value = $compartment->reval($value); + # If the value is a float number like N.0 - reval turns it into int N + # even if it's quoted. + if ($value =~ /^['"]?\d+\.\d+['"]?$/ ) { + log_debug ('$value is a float number so no need to reval() it'); + } + else { + $value = $compartment->reval($value); + } for my $component (split(/\./, $option)) { if (ref($valref) eq 'SCALAR' && defined(${$valref})) { diff --git a/t/test_ngcpcfg_set_and_del.py b/t/test_ngcpcfg_set_and_del.py index 3676746f..a8bd9d40 100644 --- a/t/test_ngcpcfg_set_and_del.py +++ b/t/test_ngcpcfg_set_and_del.py @@ -739,6 +739,29 @@ aaa: assert "" in out.stderr assert out.returncode == 0 + +@pytest.mark.tt_16903 +def test_set_float_number(ngcpcfgcli, tmpdir): + tmpfile = tmpdir.join("tmpfile.txt") + tmpfile.write( + """--- +aaa: + bbb: '' +""" + ) + out = ngcpcfgcli("set", str(tmpfile), "aaa.bbb=1.0") + assert ( + tmpfile.read() + == """--- +aaa: + bbb: '1.0' +""" + ) + assert "" in out.stdout + assert "" in out.stderr + assert out.returncode == 0 + + ############################################################### # ngcpcfg del ###############################################################