def test_ignore_known_binary_files(self): fs = Mock([ ("stat", ["."], {}, trim.StatResult(isDir=True)), ("listdir", ["."], {}, ["image.png", "somescript.pyc"]), ]) outputStream = StringIO() t = Trim(fs=fs, stdout=outputStream) t.process(".") output = outputStream.getvalue() self.assertTrue(fs.everything_called()) self.assertEqual(output, "")
def test_ignore_dotfiles(self): fs = Mock([ ("stat", ["."], {}, trim.StatResult(isDir=True)), ("listdir", ["."], {}, [".hello.txt"]), ]) outputStream = StringIO() t = Trim(fs=fs, stdout=outputStream) t.process(".") output = outputStream.getvalue() self.assertTrue(fs.everything_called()) self.assertEqual(output, "")
def test_ignore_too_big_files(self): fs = Mock([ ("stat", ["."], {}, trim.StatResult(isDir=True)), ("listdir", ["."], {}, ["somebigfile"]), ("stat", ["./somebigfile"], {}, trim.StatResult(size=1001001, isFile=True)), ]) outputStream = StringIO() t = Trim(fs=fs, stdout=outputStream) t.process(".") output = outputStream.getvalue() self.assertTrue(fs.everything_called()) self.assertEqual(output, "")
def test_trim_file_dry_run(self): fs = Mock([ ("stat", ["."], {}, trim.StatResult(isDir=True)), ("listdir", ["."], {}, ["hello.txt"]), ("stat", ["./hello.txt"], {}, trim.StatResult(size=7, isFile=True)), ("get_contents", ["./hello.txt"], {}, "Hello \n"), ]) outputStream = StringIO() t = Trim(fs=fs, stdout=outputStream, dryRun=True) t.process(".") output = outputStream.getvalue() self.assertTrue(fs.everything_called(), fs) self.assertEqual(output, "./hello.txt\n")