trying to fix timing bug

stix2.0
= 2017-11-29 12:50:13 -05:00
parent 52a052d4dd
commit 742d249ee0
2 changed files with 10 additions and 3 deletions

View File

@ -223,8 +223,8 @@ def test_remove_custom_stix_property():
mal_nc = stix2.utils.remove_custom_stix(mal)
assert "x_custom" not in mal_nc
assert stix2.utils.parse_into_datetime(mal["modified"], precision="microsecond") < stix2.utils.parse_into_datetime(mal_nc["modified"],
precision="microsecond")
assert stix2.utils.parse_into_datetime(mal["modified"], precision="millisecond") < stix2.utils.parse_into_datetime(mal_nc["modified"],
precision="millisecond")
def test_remove_custom_stix_object():

View File

@ -303,7 +303,14 @@ def remove_custom_stix(stix_obj):
# add to set the custom properties we want to get rid of (with their value=None)
props.extend(custom_props)
return new_version(stix_obj, **(dict(props)))
new_obj = new_version(stix_obj, **(dict(props)))
while parse_into_datetime(new_obj["modified"]) == parse_into_datetime(stix_obj["modified"]):
# Prevents bug when fast computation allows multiple STIX object
# versions to be created in single unit of time
new_obj = new_version(stix_obj, **(dict(props)))
return new_obj
else:
return stix_obj