From a514c5a3df51464c60c30d6a92b06d250242d095 Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Sun, 29 Oct 2017 00:09:13 -0400 Subject: [PATCH] Add test for _register_type() --- stix2/test/test_custom.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/stix2/test/test_custom.py b/stix2/test/test_custom.py index 48529b9..3bd79bc 100644 --- a/stix2/test/test_custom.py +++ b/stix2/test/test_custom.py @@ -483,3 +483,13 @@ def test_parse_observable_with_unregistered_custom_extension(): with pytest.raises(ValueError) as excinfo: stix2.parse_observable(input_str) assert "Can't parse Unknown extension type" in str(excinfo.value) + + +def test_register_custom_object(): + # Not the way to register custom object. + class CustomObject2(object): + _type = 'awesome-object' + + stix2._register_type(CustomObject2) + # Note that we will always check against newest OBJ_MAP. + assert (CustomObject2._type, CustomObject2) in stix2.OBJ_MAP.items()