From 897e884217e93aa2b3bc76cb6bf242be71400683 Mon Sep 17 00:00:00 2001 From: Chris Lenk Date: Thu, 2 Apr 2020 04:46:11 -0400 Subject: [PATCH] Fix some testing --- .travis.yml | 2 +- stix2/core.py | 7 ++----- stix2/test/v20/test_custom.py | 3 +-- tox.ini | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 018aefe..81141d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -sudo: false +os: linux language: python cache: pip dist: xenial diff --git a/stix2/core.py b/stix2/core.py index 2f8de3e..dd7aac1 100644 --- a/stix2/core.py +++ b/stix2/core.py @@ -325,11 +325,8 @@ def _register_observable_extension( EXT_MAP = STIX2_OBJ_MAPS[v]['observable-extensions'] try: - try: - if ext_type in EXT_MAP[observable_type].keys(): - raise DuplicateRegistrationError("Observable Extension", ext_type) - except AttributeError: - pass + if ext_type in EXT_MAP[observable_type].keys(): + raise DuplicateRegistrationError("Observable Extension", ext_type) EXT_MAP[observable_type][ext_type] = new_extension except KeyError: if observable_type not in OBJ_MAP_OBSERVABLE: diff --git a/stix2/test/v20/test_custom.py b/stix2/test/v20/test_custom.py index 4aee66e..346f06b 100644 --- a/stix2/test/v20/test_custom.py +++ b/stix2/test/v20/test_custom.py @@ -1080,8 +1080,7 @@ def test_register_duplicate_observable_with_version(): assert "cannot be registered again" in str(excinfo.value) -@pytest.mark.xfail(reason="The default version is no longer 2.0", condition=stix2.DEFAULT_VERSION != "2.0") -def test_register_marking_with_no_version(): +def test_register_marking_with_version(): @stix2.v20.CustomMarking( 'x-new-obj-2', [ ('property1', stix2.properties.StringProperty(required=True)), diff --git a/tox.ini b/tox.ini index d34aac1..aa0472a 100644 --- a/tox.ini +++ b/tox.ini @@ -8,11 +8,11 @@ deps = pytest pytest-cov coverage - taxii2-client + taxii2-client<1.0.0 fuzzywuzzy haversine python-Levenshtein - medallion + medallion<2.0.0 commands = python -m pytest --cov=stix2 stix2/test/ --cov-report term-missing -W ignore::stix2.exceptions.STIXDeprecationWarning