Skip to content

Commit

Permalink
Fix float norm for Str type
Browse files Browse the repository at this point in the history
  • Loading branch information
Cisphyx committed Jun 6, 2024
1 parent 0e74d28 commit 4980ecc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion synapse/lib/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1762,7 +1762,7 @@ def _normNumber(self, valu):

def _normPyFloat(self, valu):
deci = s_common.hugectx.create_decimal(str(valu))
return format(deci, 'f'), {}
return self._normPyStr(format(deci, 'f'))

def _normPyStr(self, valu):

Expand Down
1 change: 1 addition & 0 deletions synapse/tests/test_lib_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,7 @@ def test_str(self):
self.eq('hehe', enums.norm('hehe')[0])
self.eq('haha', enums.norm('haha')[0])
self.eq('zork', enums.norm('zork')[0])
self.raises(s_exc.BadTypeValu, enums.norm, 1.23)
self.raises(s_exc.BadTypeValu, enums.norm, 'zing')

strsubs = model.type('str').clone({'regex': r'(?P<first>[ab]+)(?P<last>[zx]+)'})
Expand Down
1 change: 1 addition & 0 deletions synapse/tests/test_model_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async def test_model_filebytes(self):
self.raises(s_exc.BadTypeValu, fbyts.norm, 'guid:0101')
self.raises(s_exc.BadTypeValu, fbyts.norm, 'helo:moto')
self.raises(s_exc.BadTypeValu, fbyts.norm, f'sha256:{s_common.guid()}')
self.raises(s_exc.BadTypeValu, fbyts.norm, 1.23)

nodes = await core.nodes('''
[ file:bytes=$byts
Expand Down

0 comments on commit 4980ecc

Please sign in to comment.