Skip to content

Commit

Permalink
WIP: Try harder to disable the cache for testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
gtback committed Jan 13, 2017
1 parent 2ff564c commit 2dace26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions stix2validator/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def assertTrueWithOptions(self, instance, **kwargs):
kwargs: Any number of keyword arguments to be passed to the
ValidationOptions constructor.
"""
if 'no_cache' not in kwargs:
kwargs['no_cache'] = True
if 'strict' in kwargs:
options = ValidationOptions(schema_dir=SCHEMA_DIR, **kwargs)
else:
Expand All @@ -44,6 +46,8 @@ def assertFalseWithOptions(self, instance, **kwargs):
kwargs: Any number of keyword arguments to be passed to the
ValidationOptions constructor.
"""
if 'no_cache' not in kwargs:
kwargs['no_cache'] = True
if 'strict' in kwargs:
options = ValidationOptions(schema_dir=SCHEMA_DIR, **kwargs)
else:
Expand Down
4 changes: 3 additions & 1 deletion stix2validator/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,9 @@ def schema_validate(instance, options):
raise SchemaInvalidError('Invalid JSON schema: ' + str(e))

# Cache data from external sources; used in some checks
if not options.no_cache:
if options.no_cache:
requests_cache.uninstall_cache()
else:
requests_cache.install_cache(expire_after=datetime.timedelta(weeks=1))
if options.refresh_cache:
now = datetime.datetime.utcnow()
Expand Down

0 comments on commit 2dace26

Please sign in to comment.