def test_ls_abominate(): """recursive list of directory""" # setup mkdir('work') with cd('work'): d1 = to_path('d1') mkdir(d1) d1d1 = to_path('d1/d1') mkdir(d1d1) d1d2 = to_path('d1/d2') mkdir(d1d2) d1d1f1 = to_path('d1/d1/f1') touch(d1d1f1) d1d2f2 = to_path('d1/d2/f2') touch(d1d2f2) # run test paths = ls('.', select='**/*') # check assert set(str(f) for f in paths) == set( ['d1', 'd1/d1', 'd1/d2', 'd1/d1/f1', 'd1/d2/f2']) # cleanup rm('work')
def test_ls_abominate(): """recursive list of directory""" # setup mkdir("work") with cd("work"): d1 = to_path("d1") mkdir(d1) d1d1 = to_path("d1/d1") mkdir(d1d1) d1d2 = to_path("d1/d2") mkdir(d1d2) d1d1f1 = to_path("d1/d1/f1") touch(d1d1f1) d1d2f2 = to_path("d1/d2/f2") touch(d1d2f2) # run test paths = ls(".", select="**/*") # check assert set(str(f) for f in paths) == set( ["d1", "d1/d1", "d1/d2", "d1/d1/f1", "d1/d2/f2"]) # cleanup rm("work")
def test_ls_abominate(): """recursive list of directory""" # setup mkdir('work') with cd('work'): d1 = to_path('d1') mkdir(d1) d1d1 = to_path('d1/d1') mkdir(d1d1) d1d2 = to_path('d1/d2') mkdir(d1d2) d1d1f1 = to_path('d1/d1/f1') touch(d1d1f1) d1d2f2 = to_path('d1/d2/f2') touch(d1d2f2) # run test paths = ls('.', select='**/*') # check assert set(str(f) for f in paths) == set( ['d1', 'd1/d1', 'd1/d2', 'd1/d1/f1', 'd1/d2/f2'] ) # cleanup rm('work')
def test_chmod_gathering(): """change mode of a multiple files""" # setup f1 = to_path('f1') f2 = to_path('f2') touch(f1, f2) # run test for i in range(8): chmod(i, f1, f2) # 0o100000 represents a regular file assert f1.stat().st_mode == 0o100000 + i assert getmod(f1) == i assert f2.stat().st_mode == 0o100000 + i assert getmod(f2) == i chmod(8 * i, f1, f2) assert f1.stat().st_mode == 0o100000 + 8 * i assert getmod(f1) == 8 * i assert f2.stat().st_mode == 0o100000 + 8 * i assert getmod(f2) == 8 * i chmod(8 * 8 * i, f1, f2) assert f1.stat().st_mode == 0o100000 + 8 * 8 * i assert f2.stat().st_mode == 0o100000 + 8 * 8 * i assert getmod(f1) == 8 * 8 * i assert getmod(f2) == 8 * 8 * i # cleanup rm(f1, f2)
def initialize_configs(initialize): with cd(tests_dir): cp("CONFIGS", ".config/emborg") rm(".config/emborg/subdir") for p in lsf(".config/emborg"): contents = p.read_text() contents = contents.replace('⟪EMBORG⟫', emborg_dir) p.write_text(contents) touch(".config/.nobackup")
def test_rm_downturn(): """remove existing file""" # setup f1 = to_path('f1') touch(f1) # run test rm(f1) # check assert not f1.exists()
def test_mkdir_cymbal(): """attempt to make a directory over an existing file""" # setup f1 = to_path('f1') touch(f1) # run test with pytest.raises(OSError): mkdir(f1) # cleanup rm(f1)
def test_touch_endorse(): """touch a new file""" # setup f1 = to_path("f1") # run test touch(f1) # check assert f1.is_file() # cleanup rm(f1)
def test_touch_endorse(): """touch a new file""" # setup f1 = to_path('f1') # run test touch(f1) # check assert f1.is_file() # cleanup rm(f1)
def test_rm_ground(): """remove two files""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test rm(f1, f2) # check assert not f1.exists() assert not f2.exists()
def test_ln_ground(): """link to a pre-existing name""" # setup f1 = to_path("f1") touch(f1) f2 = to_path("f2") touch(f2) # run test with pytest.raises(OSError): ln(f1, f2) # cleanup rm(f1, f2)
def test_touch_downturn(): """touch an existing file""" # setup f1 = to_path("f1") touch(f1) # run test touch(f1) # check assert f1.is_file() # cleanup rm(f1)
def test_ln_ground(): """link to a pre-existing name""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test with pytest.raises(OSError): ln(f1, f2) # cleanup rm(f1, f2)
def test_touch_downturn(): """touch an existing file""" # setup f1 = to_path('f1') touch(f1) # run test touch(f1) # check assert f1.is_file() # cleanup rm(f1)
def test_mv_cymbal(): """move two files to a new directory""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) d1 = to_path('d2') # run test with pytest.raises(OSError): mv(f1, f2, d1) # cleanup rm(f1, f2, d1)
def test_mv_incense(): """move two files into a nonexistent directory""" # setup d1 = to_path('d1') f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test with pytest.raises(OSError): mv([f1, f2], d1) # cleanup rm(d1, f1, f2)
def test_cp_cymbal(): """copy two files to a new directory""" # setup d1 = to_path('d1') f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test with pytest.raises(OSError): cp(f1, f2, d1) # cleanup rm(f1, f2, d1)
def test_cp_dealer(): """copy two files into a nonexistent directory""" # setup d1 = 'd1' f1 = 'f1' touch(f1) f2 = 'f2' touch(f2) # run test with pytest.raises(OSError): cp([f1, f2], d1) # cleanup rm(f1, f2)
def test_cp_downturn(): """copy file to new file""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') # run test cp(f1, f2) # check assert f2.is_file() # cleanup rm(f1, f2)
def test_cp_adieu(): """copy two files to a new directory""" # setup d1 = 'd1' f1 = 'f1' touch(f1) f2 = 'f2' touch(f2) # run test with pytest.raises(OSError): cp(f1, f2, d1) # cleanup rm(f1, f2, d1)
def test_cp_cymbal(): """copy two files to a new directory""" # setup d1 = to_path("d1") f1 = to_path("f1") touch(f1) f2 = to_path("f2") touch(f2) # run test with pytest.raises(OSError): cp(f1, f2, d1) # cleanup rm(f1, f2, d1)
def test_cp_dealer(): """copy two files into a nonexistent directory""" # setup d1 = "d1" f1 = "f1" touch(f1) f2 = "f2" touch(f2) # run test with pytest.raises(OSError): cp([f1, f2], d1) # cleanup rm(f1, f2)
def test_cp_demystify(): """copy file to new file""" # setup f1 = "f1" touch(f1) f2 = "f2" # run test cp(f1, f2) # check assert to_path(f2).is_file() # cleanup rm(f1, f2)
def test_cp_demystify(): """copy file to new file""" # setup f1 = 'f1' touch(f1) f2 = 'f2' # run test cp(f1, f2) # check assert to_path(f2).is_file() # cleanup rm(f1, f2)
def test_mv_cymbal(): """move two files to a new directory""" # setup f1 = to_path("f1") touch(f1) f2 = to_path("f2") touch(f2) d1 = to_path("d2") # run test with pytest.raises(OSError): mv(f1, f2, d1) # cleanup rm(f1, f2, d1)
def test_cp_incense(): """copy two files into a nonexistent directory""" # setup d1 = to_path("d1") f1 = to_path("f1") touch(f1) f2 = to_path("f2") touch(f2) # run test with pytest.raises(OSError): cp([f1, f2], d1) # cleanup rm(f1, f2)
def test_touch_cymbal(): """touch multiple files""" # setup f1 = to_path("f1") f2 = to_path("f2") # run test touch([f1, f2]) # check assert f1.is_file() assert f2.is_file() # cleanup rm(f1, f2)
def test_cp_adieu(): """copy two files to a new directory""" # setup d1 = "d1" f1 = "f1" touch(f1) f2 = "f2" touch(f2) # run test with pytest.raises(OSError): cp(f1, f2, d1) # cleanup rm(f1, f2, d1)
def test_touch_ground(): """touch multiple files""" # setup f1 = to_path('f1') f2 = to_path('f2') # run test touch(f1, f2) # check assert f1.is_file() assert f2.is_file() # cleanup rm(f1, f2)
def test_touch_cymbal(): """touch multiple files""" # setup f1 = to_path('f1') f2 = to_path('f2') # run test touch([f1, f2]) # check assert f1.is_file() assert f2.is_file() # cleanup rm(f1, f2)
def test_cp_downturn(): """copy file to new file""" # setup f1 = to_path("f1") touch(f1) f2 = to_path("f2") # run test cp(f1, f2) # check assert f2.is_file() # cleanup rm(f1, f2)
def test_cp_theorem(): """copy file to existing file""" # setup f1 = 'f1' touch(f1) f2 = 'f2' touch(f2) # run test cp(f1, f2) # check assert to_path(f2).is_file() # cleanup rm(f1, f2)
def test_cp_gathering(): """copy file into an existing directory""" # setup d1 = to_path('d1') mkdir(d1) f1 = to_path('f1') touch(f1) # run test cp(f1, d1) # check assert to_path('d1/f1').is_file() # cleanup rm(d1)
def test_rm_cymbal(): """remove directory""" # setup d1 = to_path('d1') mkdir(d1) d1f1 = to_path('d1/f1') touch(d1f1) f2 = to_path('f2') touch(f2) # run test rm(d1, f2) # check assert not d1.exists() assert not f2.exists()
def test_ls_narrow(): """list files with select constraint""" # setup f1 = to_path("f1") touch(f1) f2 = to_path("f2") touch(f2) # run test paths = ls(f1, f2, select="*2") # check assert set(str(f) for f in paths) == set(["f2"]) # cleanup rm(f1, f2)
def test_ls_rissole(): """list files""" # setup f1 = to_path("f1") touch(f1) f2 = to_path("f2") touch(f2) # run test paths = ls(f1, f2) # check assert set(str(f) for f in paths) == set(["f1", "f2"]) # cleanup rm(f1, f2)
def test_cp_endorse(): """copy file to existing file""" # setup f1 = to_path("f1") touch(f1) f2 = to_path("f2") touch(f2) # run test cp(f1, f2) # check assert f2.is_file() # cleanup rm(f1, f2)
def test_cp_endorse(): """copy file to existing file""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test cp(f1, f2) # check assert f2.is_file() # cleanup rm(f1, f2)
def test_lsd_rissole(): """list files""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test files = lsd(f1, f2) # check assert set(str(f) for f in files) == set() # cleanup rm(f1, f2)
def test_mv_downturn(): """rename file""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') # run test mv(f1, f2) # check assert f2.is_file() assert not f1.exists() # cleanup rm(f1, f2)
def test_cp_theorem(): """copy file to existing file""" # setup f1 = "f1" touch(f1) f2 = "f2" touch(f2) # run test cp(f1, f2) # check assert to_path(f2).is_file() # cleanup rm(f1, f2)
def test_lsd_rissole(): """list files""" # setup f1 = to_path("f1") touch(f1) f2 = to_path("f2") touch(f2) # run test files = lsd(f1, f2) # check assert set(str(f) for f in files) == set() # cleanup rm(f1, f2)
def test_lsf_rissole(): """list files""" # setup f1 = to_path("f1") touch(f1) f2 = to_path("f2") touch(f2) # run test files = lsf(f1, f2) # check assert set(str(f) for f in files) == set(["f1", "f2"]) # cleanup rm(f1, f2)
def test_mv_downturn(): """rename file""" # setup f1 = to_path("f1") touch(f1) f2 = to_path("f2") # run test mv(f1, f2) # check assert f2.is_file() assert not f1.exists() # cleanup rm(f1, f2)
def test_lsf_narrow(): """list files with select constraint""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test files = lsf(f1, f2, select='*2') # check assert set(str(f) for f in files) == set(['f2']) # cleanup rm(f1, f2)
def test_lsf_rissole(): """list files""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test files = lsf(f1, f2) # check assert set(str(f) for f in files) == set(['f1', 'f2']) # cleanup rm(f1, f2)
def test_lsf_narrow(): """list files with select constraint""" # setup f1 = to_path("f1") touch(f1) f2 = to_path("f2") touch(f2) # run test files = lsf(f1, f2, select="*2") # check assert set(str(f) for f in files) == set(["f2"]) # cleanup rm(f1, f2)
def test_ls_narrow(): """list files with select constraint""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test paths = ls(f1, f2, select='*2') # check assert set(str(f) for f in paths) == set(['f2']) # cleanup rm(f1, f2)
def test_ls_rissole(): """list files""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test paths = ls(f1, f2) # check assert set(str(f) for f in paths) == set(['f1', 'f2']) # cleanup rm(f1, f2)
def test_cp_gathering(): """copy file into an existing directory""" # setup d1 = to_path("d1") mkdir(d1) f1 = to_path("f1") touch(f1) # run test cp(f1, d1) # check assert to_path("d1/f1").is_file() # cleanup rm(d1)
def test_cp_convict(): """copy directory into an nonexistent directory""" # setup d1 = 'd1' mkdir(d1) f1 = 'd1/f1' touch(f1) d2 = 'd2' # run test cp(d1, d2) # check assert to_path('d2/f1').is_file() # cleanup rm(d1, d2)
def test_mv_endorse(): """rename file, replacing existing file""" # setup f1 = to_path('f1') touch(f1) f2 = to_path('f2') touch(f2) # run test mv(f1, f2) # check assert f2.is_file() assert not f1.exists() # cleanup rm(f1, f2)
def test_mv_gathering(): """move file into an existing directory""" # setup d1 = to_path('d1') mkdir(d1) f1 = to_path('f1') touch(f1) # run test mv(f1, d1) # check assert to_path('d1/f1').is_file() assert not f1.exists() # cleanup rm(d1, f1)
def test_chmod_ground(): """change mode of a single file""" # setup f1 = 'f1' touch(f1) # run test for i in range(8): chmod(i, f1) # 0o100000 represents a regular file assert to_path(f1).stat().st_mode == 0o100000 + i chmod(8*i, f1) assert to_path(f1).stat().st_mode == 0o100000 + 8*i chmod(8*8*i, f1) assert to_path(f1).stat().st_mode == 0o100000 + 8*8*i # cleanup rm(f1)
def test_mv_swine(): """rename directory""" # setup d1 = to_path('d1') mkdir(d1) f1 = to_path('d1/f1') touch(f1) d2 = to_path('d2') # run test mv(d1, d2) # check assert to_path('d2/f1').is_file() assert not d1.exists() # cleanup rm(d1, d2)