コード例 #1
0
ファイル: io_export_test.py プロジェクト: grigorisg9gr/menpo
def test_export_pickle_with_path_uses_open(mock_open, exists, pickle_dump):
    exists.return_value = False
    fake_path = str(_norm_path('fake.pkl.gz'))
    mock_open_enter = MagicMock()
    # Make sure the name attribute returns the path
    mock_open_enter.__enter__.return_value.configure_mock(name=fake_path)
    mock_open.return_value = mock_open_enter
    mio.export_pickle(test_lg, fake_path)
    assert pickle_dump.call_count == 1
    mock_open.assert_called_with(fake_path, 'wb')
コード例 #2
0
def test_export_pickle_with_path_uses_open(mock_open, exists, pickle_dump):
    exists.return_value = False
    fake_path = str(_norm_path('fake.pkl.gz'))
    mock_open_enter = MagicMock()
    # Make sure the name attribute returns the path
    mock_open_enter.__enter__.return_value.configure_mock(name=fake_path)
    mock_open.return_value = mock_open_enter
    mio.export_pickle(test_lg, fake_path)
    assert pickle_dump.call_count == 1
    mock_open.assert_called_with(fake_path, 'wb')
コード例 #3
0
ファイル: io_export_test.py プロジェクト: luukhoavn/menpo
def test_export_pickle_with_path_uses_open(mock_open, exists, pickle_dump):
    exists.return_value = False
    fake_path = _norm_path("fake.pkl.gz")
    mock_open_enter = MagicMock()
    # Make sure the name attribute returns the path
    mock_open_enter.__enter__.return_value.configure_mock(name=fake_path)
    mock_open.return_value = mock_open_enter
    mio.export_pickle(test_lg, fake_path)
    pickle_dump.assert_called_once()
    mock_open.assert_called_once_with(fake_path, "wb")