import pytest import osex import os def test_single_file(tmpdir): os.chdir(tmpdir.strpath) os.mknod("file") assert os.path.exists("file") osex.append_to_name("file", "-") assert not os.path.exists("file") assert os.path.exists("file-") def test_single_dir(tmpdir): os.chdir(tmpdir.strpath) os.mkdir("dir") assert os.path.exists("dir") osex.append_to_name("dir", "+") assert not os.path.exists("dir") assert os.path.exists("dir+") def test_multiple_files(tmpdir): os.chdir(tmpdir.strpath) # file 1 os.mknod("file") assert os.path.exists("file") osex.append_to_name("file", "-") assert not os.path.exists("file") assert os.path.exists("file-") # file 2 os.mknod("file") assert os.path.exists("file") osex.append_to_name("file", "-") assert not os.path.exists("file") assert os.path.exists("file-") assert os.path.exists("file-1") # file 3 os.mknod("file") assert os.path.exists("file") osex.append_to_name("file", "-") assert not os.path.exists("file") assert os.path.exists("file-") assert os.path.exists("file-1") assert os.path.exists("file-2") def test_empty_suffix(tmpdir): os.chdir(tmpdir.strpath) # file 1 os.mknod("file") assert os.path.exists("file") osex.append_to_name("file", "") assert not os.path.exists("file") assert os.path.exists("file1") # file 2 os.mknod("file") assert os.path.exists("file") osex.append_to_name("file", "") assert not os.path.exists("file") assert os.path.exists("file1") assert os.path.exists("file2") # file 3 os.mknod("file") assert os.path.exists("file") osex.append_to_name("file", "") assert not os.path.exists("file") assert os.path.exists("file1") assert os.path.exists("file2") assert os.path.exists("file3")