From e748923f1906cc5da95c236ecdc7c0378d5967a3 Mon Sep 17 00:00:00 2001 From: "Desai, Kartikey H" Date: Wed, 17 Apr 2019 10:08:34 -0400 Subject: [PATCH] Fixes #248 --- stix2/base.py | 4 ++-- stix2/test/v20/test_object_markings.py | 2 -- stix2/test/v21/test_object_markings.py | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/stix2/base.py b/stix2/base.py index a6bafff..9fcdf56 100644 --- a/stix2/base.py +++ b/stix2/base.py @@ -143,12 +143,12 @@ class _STIXBase(collections.Mapping): if custom_props: self.__allow_custom = True - # Remove any keyword arguments whose value is None + # Remove any keyword arguments whose value is None or [] (i.e. empty list) setting_kwargs = {} props = kwargs.copy() props.update(custom_props) for prop_name, prop_value in props.items(): - if prop_value is not None: + if prop_value is not None and prop_value != []: setting_kwargs[prop_name] = prop_value # Detect any missing required properties diff --git a/stix2/test/v20/test_object_markings.py b/stix2/test/v20/test_object_markings.py index 495c45a..156c42d 100644 --- a/stix2/test/v20/test_object_markings.py +++ b/stix2/test/v20/test_object_markings.py @@ -107,7 +107,6 @@ def test_add_markings_combination(): "data", [ ([""]), (""), - ([]), ([MARKING_IDS[0], 456]), ], ) @@ -576,7 +575,6 @@ def test_set_marking(): @pytest.mark.parametrize( "data", [ - ([]), ([""]), (""), ([MARKING_IDS[4], 687]), diff --git a/stix2/test/v21/test_object_markings.py b/stix2/test/v21/test_object_markings.py index d43aad5..7b19d4f 100644 --- a/stix2/test/v21/test_object_markings.py +++ b/stix2/test/v21/test_object_markings.py @@ -106,7 +106,6 @@ def test_add_markings_combination(): "data", [ ([""]), (""), - ([]), ([MARKING_IDS[0], 456]), ], ) @@ -575,7 +574,6 @@ def test_set_marking(): @pytest.mark.parametrize( "data", [ - ([]), ([""]), (""), ([MARKING_IDS[4], 687]),