Fix deprecated 3.6 backslash-character pairs
(https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior)stix2.0
parent
1d22c757ef
commit
3e048ef325
|
@ -42,7 +42,7 @@ def test_external_reference_capec():
|
||||||
)
|
)
|
||||||
|
|
||||||
assert str(ref) == CAPEC
|
assert str(ref) == CAPEC
|
||||||
assert re.match("ExternalReference\(source_name=u?'capec', external_id=u?'CAPEC-550'\)", repr(ref))
|
assert re.match("ExternalReference\\(source_name=u?'capec', external_id=u?'CAPEC-550'\\)", repr(ref))
|
||||||
|
|
||||||
|
|
||||||
CAPEC_URL = """{
|
CAPEC_URL = """{
|
||||||
|
@ -109,7 +109,7 @@ def test_external_reference_offline():
|
||||||
)
|
)
|
||||||
|
|
||||||
assert str(ref) == OFFLINE
|
assert str(ref) == OFFLINE
|
||||||
assert re.match("ExternalReference\(source_name=u?'ACME Threat Intel', description=u?'Threat report'\)", repr(ref))
|
assert re.match("ExternalReference\\(source_name=u?'ACME Threat Intel', description=u?'Threat report'\\)", repr(ref))
|
||||||
# Yikes! This works
|
# Yikes! This works
|
||||||
assert eval("stix2." + repr(ref)) == ref
|
assert eval("stix2." + repr(ref)) == ref
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ def test_parse_malware(data):
|
||||||
|
|
||||||
|
|
||||||
def test_parse_malware_invalid_labels():
|
def test_parse_malware_invalid_labels():
|
||||||
data = re.compile('\[.+\]', re.DOTALL).sub('1', EXPECTED_MALWARE)
|
data = re.compile('\\[.+\\]', re.DOTALL).sub('1', EXPECTED_MALWARE)
|
||||||
with pytest.raises(ValueError) as excinfo:
|
with pytest.raises(ValueError) as excinfo:
|
||||||
stix2.parse(data)
|
stix2.parse(data)
|
||||||
assert "Invalid value for Malware 'labels'" in str(excinfo.value)
|
assert "Invalid value for Malware 'labels'" in str(excinfo.value)
|
||||||
|
|
|
@ -319,13 +319,13 @@ def test_invalid_binary_constant():
|
||||||
|
|
||||||
def test_escape_quotes_and_backslashes():
|
def test_escape_quotes_and_backslashes():
|
||||||
exp = stix2.MatchesComparisonExpression("file:name",
|
exp = stix2.MatchesComparisonExpression("file:name",
|
||||||
"^Final Report.+\.exe$")
|
"^Final Report.+\\.exe$")
|
||||||
assert str(exp) == "file:name MATCHES '^Final Report.+\\\\.exe$'"
|
assert str(exp) == "file:name MATCHES '^Final Report.+\\\\.exe$'"
|
||||||
|
|
||||||
|
|
||||||
def test_like():
|
def test_like():
|
||||||
exp = stix2.LikeComparisonExpression("directory:path",
|
exp = stix2.LikeComparisonExpression("directory:path",
|
||||||
"C:\Windows\%\\foo")
|
"C:\\Windows\\%\\foo")
|
||||||
assert str(exp) == "directory:path LIKE 'C:\\\\Windows\\\\%\\\\foo'"
|
assert str(exp) == "directory:path LIKE 'C:\\\\Windows\\\\%\\\\foo'"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue