Skip to content

Commit

Permalink
Merge f59e652 into 985567b
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldemarmiesse committed Jul 23, 2019
2 parents 985567b + f59e652 commit 3d8c063
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 34 deletions.
25 changes: 25 additions & 0 deletions tests/test_observers/dummy_exp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import datetime


T1 = datetime.datetime(1999, 5, 4, 3, 2, 1)
T2 = datetime.datetime(1999, 5, 5, 5, 5, 5)
T3 = datetime.datetime(1999, 5, 5, 5, 10, 5)


def sample_run():
exp = {'name': 'test_exp', 'sources': [], 'doc': '', 'base_dir': '/tmp'}
host = {'hostname': 'test_host', 'cpu_count': 1, 'python_version': '3.4'}
config = {'config': 'True', 'foo': 'bar', 'answer': 42}
command = 'run'
meta_info = {'comment': 'test run'}
return {
'_id': 'FEDCBA9876543210',
'ex_info': exp,
'command': command,
'host_info': host,
'start_time': T1,
'config': config,
'meta_info': meta_info,
}


21 changes: 2 additions & 19 deletions tests/test_observers/test_file_storage_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,10 @@
from sacred.observers.file_storage import FileStorageObserver
from sacred.metrics_logger import ScalarMetricLogEntry, linearize_metrics

from .dummy_exp import T1, T2, sample_run

T1 = datetime.datetime(1999, 5, 4, 3, 2, 1, 0)
T2 = datetime.datetime(1999, 5, 5, 5, 5, 5, 5)


@pytest.fixture()
def sample_run():
exp = {'name': 'test_exp', 'sources': [], 'doc': '', 'base_dir': '/tmp'}
host = {'hostname': 'test_host', 'cpu_count': 1, 'python_version': '3.4'}
config = {'config': 'True', 'foo': 'bar', 'answer': 42}
command = 'run'
meta_info = {'comment': 'test run'}
return {
'_id': 'FEDCBA9876543210',
'ex_info': exp,
'command': command,
'host_info': host,
'start_time': T1,
'config': config,
'meta_info': meta_info,
}
sample_run = pytest.fixture()(sample_run)


@pytest.fixture()
Expand Down
18 changes: 3 additions & 15 deletions tests/test_observers/test_mongo_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from sacred.dependencies import get_digest
from sacred.observers.mongo import (MongoObserver, force_bson_encodeable)

T1 = datetime.datetime(1999, 5, 4, 3, 2, 1)
T2 = datetime.datetime(1999, 5, 5, 5, 5, 5)
T3 = datetime.datetime(1999, 5, 5, 5, 10, 5)
from .dummy_exp import T1, T2, T3, sample_run

sample_run = pytest.fixture()(sample_run)


def test_create_should_raise_error_on_non_pymongo_client():
Expand Down Expand Up @@ -55,18 +55,6 @@ def failing_mongo_observer():
return MongoObserver(runs, fs, metrics_collection=metrics)


@pytest.fixture()
def sample_run():
exp = {'name': 'test_exp', 'sources': [], 'doc': '', 'base_dir': '/tmp'}
host = {'hostname': 'test_host', 'cpu_count': 1, 'python_version': '3.4'}
config = {'config': 'True', 'foo': 'bar', 'answer': 42}
command = 'run'
meta_info = {'comment': 'test run'}
return {'_id': 'FEDCBA9876543210', 'ex_info': exp, 'command': command,
'host_info': host, 'start_time': T1, 'config': config,
'meta_info': meta_info, }


def test_mongo_observer_started_event_creates_run(mongo_obs, sample_run):
sample_run['_id'] = None
_id = mongo_obs.started_event(**sample_run)
Expand Down

0 comments on commit 3d8c063

Please sign in to comment.