Skip to content

Commit

Permalink
Merge pull request #953 from dwf/shut_up_sqlite
Browse files Browse the repository at this point in the history
Skip test_save_the_best with sqlite backend, restore sanity.
  • Loading branch information
rizar committed Jan 24, 2016
2 parents f5ee622 + 417dbdf commit ed481ef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions blocks/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,27 @@ def skip_if_not_available(modules=None, datasets=None, configurations=None):
raise SkipTest


def skip_if_configuration_set(configuration, value, message=None):
"""Raise SkipTest if a configuration option has a certain value.
Parameters
----------
configuration : str
Configuration option to check.
value : str
Value of `blocks.config.<attribute>` which should cause
a `SkipTest` to be raised.
message : str, optional
Reason for skipping the test.
"""
if getattr(config, configuration) == value:
if message is not None:
raise SkipTest(message)
else:
raise SkipTest


class MockAlgorithm(TrainingAlgorithm):
"""An algorithm that only saves data.
Expand Down
4 changes: 3 additions & 1 deletion tests/extensions/test_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from blocks.extensions.predicates import OnLogRecord
from blocks.main_loop import MainLoop
from blocks.utils import shared_floatx
from blocks.utils.testing import MockMainLoop
from blocks.utils.testing import MockMainLoop, skip_if_configuration_set


def test_shared_variable_modifier():
Expand Down Expand Up @@ -129,6 +129,8 @@ def after_batch(self, batch):


def test_save_the_best():
skip_if_configuration_set('log_backend', 'sqlite',
"Known to be flaky with SQLite log backend.")
with NamedTemporaryFile(dir=config.temp_dir) as dst,\
NamedTemporaryFile(dir=config.temp_dir) as dst_best:
track_cost = TrackTheBest("cost", after_epoch=False, after_batch=True)
Expand Down

0 comments on commit ed481ef

Please sign in to comment.