def test_rename_dirs(): def _walk(d): assert d == '.' yield ("", ["bazfoo"], "foofoo") def _rename(from_, to): assert from_ == "bazfoo" assert to == "bazbar" parse_arguments(["--addrename", "foo", "bar"]) rename_dirs(os_walk=_walk, os_rename=_rename)
def test_rename_target(): rename_target = "rename_target" parse_arguments(["--rename", rename_target]) def _walk(d): assert d == rename_target yield ("", ["bazfoo"], "foofoo") def _rename(from_, to): pass rename_dirs(os_walk=_walk, os_rename=_rename)
def test_pretend(): parse_arguments(["--pretend", "--rename", "bacon"]) def _walk(d): yield ("", ["bazfoo"], "foofoo") notcalled = [True] def _rename(from_, to): notcalled[0] = False rename_dirs(_walk, _rename) assert notcalled[0]