Fix make_constant when value is already a constant

Fixes #171.
stix2.0
Chris Lenk 2018-04-26 10:20:46 -04:00
parent f778a45b33
commit 4229c380a2
2 changed files with 9 additions and 0 deletions

View File

@ -147,6 +147,9 @@ class ListConstant(_Constant):
def make_constant(value):
if isinstance(value, _Constant):
return value
try:
return parse_into_datetime(value)
except ValueError:

View File

@ -372,3 +372,9 @@ def test_invalid_startstop_qualifier():
stix2.StartStopQualifier(datetime.date(2016, 6, 1),
'foo')
assert 'is not a valid argument for a Start/Stop Qualifier' in str(excinfo)
def test_make_constant_already_a_constant():
str_const = stix2.StringConstant('Foo')
result = stix2.patterns.make_constant(str_const)
assert result is str_const