pre-commit styling changes
parent
e534e41865
commit
724122db65
|
@ -392,6 +392,6 @@ def create_pattern_object(pattern, module_suffix="", module_name="", version=DEF
|
|||
|
||||
pattern_obj = pattern_class(pattern)
|
||||
builder = visitor_class(
|
||||
parser_class, module_suffix, module_name
|
||||
parser_class, module_suffix, module_name,
|
||||
)
|
||||
return pattern_obj.visit(builder)
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
AST node class overrides for testing the pattern AST builder.
|
||||
"""
|
||||
from stix2.patterns import (
|
||||
EqualityComparisonExpression,
|
||||
StartStopQualifier,
|
||||
StringConstant
|
||||
EqualityComparisonExpression, StartStopQualifier, StringConstant,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ import pytz
|
|||
|
||||
import stix2
|
||||
from stix2.pattern_visitor import create_pattern_object
|
||||
import stix2.utils
|
||||
import stix2.patterns
|
||||
import stix2.utils
|
||||
|
||||
from .pattern_ast_overrides import *
|
||||
|
||||
|
||||
|
@ -594,7 +595,7 @@ def test_list_constant():
|
|||
def test_ast_class_override_comp_equals():
|
||||
patt_ast = create_pattern_object(
|
||||
"[a:b=1]", "Testing", "stix2.test.v20.pattern_ast_overrides",
|
||||
version="2.0"
|
||||
version="2.0",
|
||||
)
|
||||
|
||||
assert isinstance(patt_ast, stix2.patterns.ObservationExpression)
|
||||
|
@ -606,20 +607,20 @@ def test_ast_class_override_string_constant():
|
|||
patt_ast = create_pattern_object(
|
||||
"[a:'b'[1].'c' < 'foo']", "Testing",
|
||||
"stix2.test.v20.pattern_ast_overrides",
|
||||
version="2.0"
|
||||
version="2.0",
|
||||
)
|
||||
|
||||
assert isinstance(patt_ast, stix2.patterns.ObservationExpression)
|
||||
assert isinstance(
|
||||
patt_ast.operand, stix2.patterns.LessThanComparisonExpression
|
||||
patt_ast.operand, stix2.patterns.LessThanComparisonExpression,
|
||||
)
|
||||
assert isinstance(
|
||||
patt_ast.operand.lhs.property_path[0].property_name,
|
||||
str
|
||||
str,
|
||||
)
|
||||
assert isinstance(
|
||||
patt_ast.operand.lhs.property_path[1].property_name,
|
||||
str
|
||||
str,
|
||||
)
|
||||
assert isinstance(patt_ast.operand.rhs, StringConstantForTesting)
|
||||
|
||||
|
@ -629,18 +630,18 @@ def test_ast_class_override_string_constant():
|
|||
def test_ast_class_override_startstop_qualifier():
|
||||
patt_ast = create_pattern_object(
|
||||
"[a:b=1] START '1993-01-20T01:33:52.592Z' STOP '2001-08-19T23:50:23.129Z'",
|
||||
"Testing", "stix2.test.v20.pattern_ast_overrides", version="2.0"
|
||||
"Testing", "stix2.test.v20.pattern_ast_overrides", version="2.0",
|
||||
)
|
||||
|
||||
assert isinstance(patt_ast, stix2.patterns.QualifiedObservationExpression)
|
||||
assert isinstance(
|
||||
patt_ast.observation_expression, stix2.patterns.ObservationExpression
|
||||
patt_ast.observation_expression, stix2.patterns.ObservationExpression,
|
||||
)
|
||||
assert isinstance(
|
||||
patt_ast.observation_expression.operand,
|
||||
EqualityComparisonExpressionForTesting
|
||||
EqualityComparisonExpressionForTesting,
|
||||
)
|
||||
assert isinstance(
|
||||
patt_ast.qualifier, StartStopQualifierForTesting
|
||||
patt_ast.qualifier, StartStopQualifierForTesting,
|
||||
)
|
||||
assert str(patt_ast) == "[a:b = 1] START '1993-01-20T01:33:52.592Z' STOP '2001-08-19T23:50:23.129Z'"
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
AST node class overrides for testing the pattern AST builder.
|
||||
"""
|
||||
from stix2.patterns import (
|
||||
EqualityComparisonExpression,
|
||||
StartStopQualifier,
|
||||
StringConstant
|
||||
EqualityComparisonExpression, StartStopQualifier, StringConstant,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -6,8 +6,9 @@ from stix2patterns.exceptions import ParseException
|
|||
|
||||
import stix2
|
||||
from stix2.pattern_visitor import create_pattern_object
|
||||
import stix2.utils
|
||||
import stix2.patterns
|
||||
import stix2.utils
|
||||
|
||||
from .pattern_ast_overrides import *
|
||||
|
||||
|
||||
|
@ -754,7 +755,7 @@ def test_parse_error():
|
|||
def test_ast_class_override_comp_equals():
|
||||
patt_ast = create_pattern_object(
|
||||
"[a:b=1]", "Testing", "stix2.test.v21.pattern_ast_overrides",
|
||||
version="2.1"
|
||||
version="2.1",
|
||||
)
|
||||
|
||||
assert isinstance(patt_ast, stix2.patterns.ObservationExpression)
|
||||
|
@ -766,20 +767,20 @@ def test_ast_class_override_string_constant():
|
|||
patt_ast = create_pattern_object(
|
||||
"[a:'b'[1].'c' < 'foo']", "Testing",
|
||||
"stix2.test.v21.pattern_ast_overrides",
|
||||
version="2.1"
|
||||
version="2.1",
|
||||
)
|
||||
|
||||
assert isinstance(patt_ast, stix2.patterns.ObservationExpression)
|
||||
assert isinstance(
|
||||
patt_ast.operand, stix2.patterns.LessThanComparisonExpression
|
||||
patt_ast.operand, stix2.patterns.LessThanComparisonExpression,
|
||||
)
|
||||
assert isinstance(
|
||||
patt_ast.operand.lhs.property_path[0].property_name,
|
||||
str
|
||||
str,
|
||||
)
|
||||
assert isinstance(
|
||||
patt_ast.operand.lhs.property_path[1].property_name,
|
||||
str
|
||||
str,
|
||||
)
|
||||
assert isinstance(patt_ast.operand.rhs, StringConstantForTesting)
|
||||
|
||||
|
@ -789,18 +790,18 @@ def test_ast_class_override_string_constant():
|
|||
def test_ast_class_override_startstop_qualifier():
|
||||
patt_ast = create_pattern_object(
|
||||
"[a:b=1] START t'1993-01-20T01:33:52.592Z' STOP t'2001-08-19T23:50:23.129Z'",
|
||||
"Testing", "stix2.test.v21.pattern_ast_overrides", version="2.1"
|
||||
"Testing", "stix2.test.v21.pattern_ast_overrides", version="2.1",
|
||||
)
|
||||
|
||||
assert isinstance(patt_ast, stix2.patterns.QualifiedObservationExpression)
|
||||
assert isinstance(
|
||||
patt_ast.observation_expression, stix2.patterns.ObservationExpression
|
||||
patt_ast.observation_expression, stix2.patterns.ObservationExpression,
|
||||
)
|
||||
assert isinstance(
|
||||
patt_ast.observation_expression.operand,
|
||||
EqualityComparisonExpressionForTesting
|
||||
EqualityComparisonExpressionForTesting,
|
||||
)
|
||||
assert isinstance(
|
||||
patt_ast.qualifier, StartStopQualifierForTesting
|
||||
patt_ast.qualifier, StartStopQualifierForTesting,
|
||||
)
|
||||
assert str(patt_ast) == "[a:b = 1] START t'1993-01-20T01:33:52.592Z' STOP t'2001-08-19T23:50:23.129Z'"
|
||||
|
|
Loading…
Reference in New Issue