def test_is_text_should_consider_empty_files_as_non_text(self): import tempfile with tempfile.NamedTemporaryFile(mode='w') as temporary_file: temporary_file.write('') temporary_file.flush() self.assertFalse(trim.is_text(temporary_file.name))
def test_is_text_should_consider_whitespace_only_as_text(self): import tempfile with tempfile.NamedTemporaryFile(mode='w') as temporary_file: temporary_file.write(' ') temporary_file.flush() self.assertTrue(trim.is_text(temporary_file.name))
def test_is_text(self): self.assertTrue(trim.is_text(os.path.join(ROOT_DIR, 'README.rst'))) self.assertTrue(trim.is_text(os.path.join(ROOT_DIR, 'trim'))) self.assertFalse(trim.is_text(sys.executable)) self.assertFalse(trim.is_text('/bin/bash')) self.assertFalse(trim.is_text('/usr/bin/env')) self.assertFalse(trim.is_text('non_existent_file'))
def test_is_text_should_consider_symlinks_as_non_text(self): self.assertFalse(trim.is_text(os.path.join(ROOT_DIR, 'trim.py')))