From 99276c92fc5beea5278742699249248f76c1feb7 Mon Sep 17 00:00:00 2001 From: Richard Piazza Date: Sun, 9 Dec 2018 21:42:24 -0500 Subject: [PATCH] flake-y again --- stix2/__init__.py | 1 - stix2/patterns.py | 3 ++- stix2/test/test_pattern_expressions.py | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/stix2/__init__.py b/stix2/__init__.py index c5cf3f3..3d70001 100644 --- a/stix2/__init__.py +++ b/stix2/__init__.py @@ -50,7 +50,6 @@ from .patterns import (AndBooleanExpression, AndObservationExpression, ReferenceObjectPathComponent, RepeatQualifier, StartStopQualifier, StringConstant, TimestampConstant, WithinQualifier) -from .STIXPatternVisitor import create_pattern_object from .utils import new_version, revoke from .v20 import * # This import will always be the latest STIX 2.X version from .version import __version__ diff --git a/stix2/patterns.py b/stix2/patterns.py index 4828b07..fec060e 100644 --- a/stix2/patterns.py +++ b/stix2/patterns.py @@ -5,6 +5,7 @@ import base64 import binascii import datetime import re +import six from .utils import parse_into_datetime @@ -14,7 +15,7 @@ def escape_quotes_and_backslashes(s): def quote_if_needed(x): - if isinstance(x, str): + if isinstance(x, six.string_types): if x.find("-") != -1: if not x.startswith("'"): return "'" + x + "'" diff --git a/stix2/test/test_pattern_expressions.py b/stix2/test/test_pattern_expressions.py index 91aee5a..c136eaa 100644 --- a/stix2/test/test_pattern_expressions.py +++ b/stix2/test/test_pattern_expressions.py @@ -4,6 +4,8 @@ import pytest import stix2 +from stix2.STIXPatternVisitor import create_pattern_object + def test_create_comparison_expression(): exp = stix2.EqualityComparisonExpression( @@ -506,12 +508,12 @@ def test_make_constant_already_a_constant(): def test_parsing_comparison_expression(): - patt_obj = stix2.create_pattern_object("[file:hashes.'SHA-256' = 'aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f']") + patt_obj = create_pattern_object("[file:hashes.'SHA-256' = 'aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f']") assert str(patt_obj) == "[file:hashes.'SHA-256' = 'aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f']" def test_parsing_qualified_expression(): - patt_obj = stix2.create_pattern_object( + patt_obj = create_pattern_object( "[network-traffic:dst_ref.type = 'domain-name' AND network-traffic:dst_ref.value = 'example.com'] REPEATS 5 TIMES WITHIN 1800 SECONDS") assert str( patt_obj) == "[network-traffic:dst_ref.type = 'domain-name' AND network-traffic:dst_ref.value = 'example.com'] REPEATS 5 TIMES WITHIN 1800 SECONDS"