Пример #1
0
def test_backup_returns_none_if_no_backup_is_done(rename, exists):
    """ The path of the backup file/dir is returned """
    exists.return_value = False
    assert mod.backup('foo') is None
Пример #2
0
def test_backup_returns_target_path(rename, exists):
    """ The path of the backup file/dir is returned """
    exists.return_value = True
    assert mod.backup('foo') == 'foo.backup'
Пример #3
0
def test_backup_normalizes(rename, exists):
    """ Backup always normalizes the path """
    exists.return_value = True
    mod.backup('\\foo\\bar\\baz')
    expected = '/foo/bar/baz'.replace('/', os.sep)
    rename.assert_called_once_with(expected, expected + '.backup')
Пример #4
0
def test_backup(rename, exists):
    """ Backup moves path to a path with .backup suffix """
    exists.return_value = True
    mod.backup('foo')
    rename.assert_called_once_with('foo', 'foo.backup')
Пример #5
0
def test_backup_returns_early_if_nothing_to_do(rename, exists):
    exists.return_value = False
    mod.backup('foo')
    assert not rename.called