Allow passing objects to Bundle as args
parent
58fccd7f7d
commit
2a1709a7de
|
@ -124,9 +124,10 @@ class Bundle(_STIXBase):
|
||||||
'objects': {},
|
'objects': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
# TODO: Allow variable number of arguments to pass "objects" to the
|
# Add any positional arguments to the 'objects' kwarg.
|
||||||
# Bundle constructor
|
if args:
|
||||||
|
kwargs['objects'] = kwargs.get('objects', []) + list(args)
|
||||||
|
|
||||||
super(Bundle, self).__init__(**kwargs)
|
super(Bundle, self).__init__(**kwargs)
|
||||||
|
|
||||||
|
|
|
@ -459,3 +459,9 @@ def test_create_bundle(indicator, malware, relationship):
|
||||||
bundle = stix2.Bundle(objects=[indicator, malware, relationship])
|
bundle = stix2.Bundle(objects=[indicator, malware, relationship])
|
||||||
|
|
||||||
assert str(bundle) == EXPECTED_BUNDLE
|
assert str(bundle) == EXPECTED_BUNDLE
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_bundle_with_positional_args(indicator, malware, relationship):
|
||||||
|
bundle = stix2.Bundle(indicator, malware, relationship)
|
||||||
|
|
||||||
|
assert str(bundle) == EXPECTED_BUNDLE
|
||||||
|
|
Loading…
Reference in New Issue