Merge pull request #172 from oasis-open/171-make-constant
Fix make_constant when value is already a constantstix2.0
commit
784893e178
|
@ -147,6 +147,9 @@ class ListConstant(_Constant):
|
||||||
|
|
||||||
|
|
||||||
def make_constant(value):
|
def make_constant(value):
|
||||||
|
if isinstance(value, _Constant):
|
||||||
|
return value
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return parse_into_datetime(value)
|
return parse_into_datetime(value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
|
@ -372,3 +372,9 @@ def test_invalid_startstop_qualifier():
|
||||||
stix2.StartStopQualifier(datetime.date(2016, 6, 1),
|
stix2.StartStopQualifier(datetime.date(2016, 6, 1),
|
||||||
'foo')
|
'foo')
|
||||||
assert 'is not a valid argument for a Start/Stop Qualifier' in str(excinfo)
|
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
|
||||||
|
|
Loading…
Reference in New Issue