From 9d08cadcfdbe6809301259d70b30bc48e63eb4b4 Mon Sep 17 00:00:00 2001 From: Michael Chisholm Date: Wed, 24 Jul 2019 16:23:19 -0400 Subject: [PATCH] Turn off the workbench test suite's side effects after each test that turns them on. These have the potential to affect subsequent tests. The side effects include automatically setting property values, and automatically appending additional values to list-valued properties. --- stix2/test/test_workbench.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stix2/test/test_workbench.py b/stix2/test/test_workbench.py index a85ab0e..0bd52af 100644 --- a/stix2/test/test_workbench.py +++ b/stix2/test/test_workbench.py @@ -259,6 +259,9 @@ def test_default_creator(): assert 'created_by_ref' not in constants.CAMPAIGN_KWARGS assert campaign.created_by_ref == constants.IDENTITY_ID + # turn off side-effects to avoid affecting future tests + set_default_creator(None) + def test_default_created_timestamp(): timestamp = "2018-03-19T01:02:03.000Z" @@ -269,6 +272,9 @@ def test_default_created_timestamp(): assert stix2.utils.format_datetime(campaign.created) == timestamp assert stix2.utils.format_datetime(campaign.modified) == timestamp + # turn off side-effects to avoid affecting future tests + set_default_created(None) + def test_default_external_refs(): ext_ref = ExternalReference( @@ -281,6 +287,9 @@ def test_default_external_refs(): assert campaign.external_references[0].source_name == "ACME Threat Intel" assert campaign.external_references[0].description == "Threat report" + # turn off side-effects to avoid affecting future tests + set_default_external_refs([]) + def test_default_object_marking_refs(): stmt_marking = StatementMarking("Copyright 2016, Example Corp") @@ -293,6 +302,9 @@ def test_default_object_marking_refs(): assert campaign.object_marking_refs[0] == mark_def.id + # turn off side-effects to avoid affecting future tests + set_default_object_marking_refs([]) + def test_workbench_custom_property_object_in_observable_extension(): ntfs = stix2.v20.NTFSExt(