def test_optional_existing_dest(self): p = self.tmppath('dest') with open(p, 'a'): pass f = ExistingFile(required=False) f.copy(p)
def test_optional_existing_dest(self): p = self.tmppath("dest") with open(p, "a"): pass f = ExistingFile(required=False) f.copy(p)
def test_required_existing_dest(self): p = self.tmppath("dest") with open(p, "a"): pass f = ExistingFile(required=True) f.copy(p)
def test_required_existing_dest(self): p = self.tmppath('dest') with open(p, 'a'): pass f = ExistingFile(required=True) f.copy(p)
def test_optional_exists_creates_unneeded_directory(self): """Demonstrate that a directory not strictly required, but specified as the path to an optional file, will be unnecessarily created. This behaviour is wrong; fixing it is tracked by Bug 972432; and this test exists to guard against unexpected changes in behaviour. """ dest = self.tmppath("dest") copier = FileCopier() copier.add("foo/bar", ExistingFile(required=False)) result = copier.copy(dest) st = os.lstat(self.tmppath("dest/foo")) self.assertFalse(stat.S_ISLNK(st.st_mode)) self.assertTrue(stat.S_ISDIR(st.st_mode)) # What's worse, we have no record that dest was created. self.assertEquals(len(result.updated_files), 0) # But we do have an erroneous record of an optional file # existing when it does not. self.assertIn(self.tmppath("dest/foo/bar"), result.existing_files)
def test_optional_missing_dest(self): f = ExistingFile(required=False) f.copy(self.tmppath("dest"))
def test_required_missing_dest(self): with self.assertRaisesRegexp(ErrorMessage, "Required existing file"): f = ExistingFile(required=True) f.copy(self.tmppath("dest"))
def test_optional_missing_dest(self): f = ExistingFile(required=False) f.copy(self.tmppath('dest'))
def test_required_missing_dest(self): with self.assertRaisesRegexp(ErrorMessage, 'Required existing file'): f = ExistingFile(required=True) f.copy(self.tmppath('dest'))