def test_ls_dotfile(self): "Shouldn't see dotfiles" nix.touch(Path(self.tdir) + '.dotrc') self.assertTrue(os.path.isfile(self.tdir + '/.dotrc')) contents = nix.ls(Path(self.tdir)) contents.sort() self.assertEqual(['bar.txt', 'foo.txt'], contents)
def test_with_tmp_contents(self): "Should kill directory contents" with Path.temp() as p: val = str(p) touch(p + 'my.txt') self.assertTrue(os.path.exists(str(p + 'my.txt'))) self.assertFalse(os.path.exists(val))
def test_ls_a_ignore_backups(self): "Should ignore ~ files even with all" nix.touch(Path(self.tdir) + 'dotrc~') self.assertTrue(os.path.isfile(self.tdir + '/dotrc~')) contents = nix.ls(self.tdir, ignore_backups=True, all=True) contents.sort() self.assertEqual(['.', '..', 'bar.txt', 'foo.txt'], contents)
def test_ls_almost_all(self): "Should see most dotfiles" nix.touch(Path(self.tdir) + '.dotrc') self.assertTrue(os.path.isfile(self.tdir + '/.dotrc')) contents = nix.ls(self.tdir, almost_all=True) contents.sort() self.assertEqual(['.dotrc', 'bar.txt', 'foo.txt'], contents)
def test_iter_dir(self): "Iterate through lines in a file" p = Path(self.tdir) touch(p + 'foo.txt') touch(p + 'bar.txt') i = ['foo.txt', 'bar.txt'] for branch in p: self.assertIn(branch, i)
def test_touch_path(self): "Create from a Path object" filestr = self.tdir + '/foo.txt' filepath = Path(filestr) nix.touch(filepath) self.assertTrue(os.path.isfile(filestr))
def setUp(self): tmpath = self.tmpath = tempfile.mktemp() self.tdir = tempfile.mkdtemp() touch(tmpath)
def setUp(self): self.tfile = tempfile.mktemp() self.tdir = tempfile.mkdtemp() nix.touch(self.tfile) nix.mkdir_p(self.tdir) self.fs = filesystem.DiskFilesystem()
def setUp(self): self.tdir = tempfile.mkdtemp() p = Path(self.tdir) nix.touch(p + 'foo.txt') nix.touch(p + 'bar.txt')
def setUp(self): self.tdir = tempfile.mkdtemp() self.src = self.tdir + '/target' nix.touch(self.src)
def test_contents_dir(self): "list of files" p = Path(self.tdir) touch(p + 'myfile.txt') self.assertIn(self.tdir + '/myfile.txt', p.contents) self.assertEqual(1, len(p.contents))
def test_touches(self): "Create a file" filepath = self.tdir + '/foo.txt' nix.touch(filepath) self.assertTrue(os.path.isfile(filepath))
def touch(self, resource): return nix.touch(resource)