def test_functions(self): if osutils.normalizes_filenames(): self.assertEqual(osutils.normalized_filename, osutils._accessible_normalized_filename) else: self.assertEqual(osutils.normalized_filename, osutils._inaccessible_normalized_filename)
def test_bad_fs_path(self): if osutils.normalizes_filenames(): # You *can't* create an illegal filename on OSX. raise tests.TestNotApplicable('OSX normalizes filenames') self.requireFeature(features.UTF8Filesystem) # We require a UTF8 filesystem, because otherwise we would need to get # tricky to figure out how to create an illegal filename. # \xb5 is an illegal path because it should be \xc2\xb5 for UTF-8 tree = self.make_branch_and_tree('tree') self.build_tree(['tree/subdir/']) tree.add('subdir') f = open('tree/subdir/m\xb5', 'wb') try: f.write('trivial\n') finally: f.close() tree.lock_read() self.addCleanup(tree.unlock) basis = tree.basis_tree() basis.lock_read() self.addCleanup(basis.unlock) e = self.assertListRaises(errors.BadFilenameEncoding, tree.iter_changes, tree.basis_tree(), want_unversioned=True) # We should display the relative path self.assertEqual('subdir/m\xb5', e.filename) self.assertEqual(osutils._fs_enc, e.fs_encoding)
def test_rename_to_denormalised_fails(self): if osutils.normalizes_filenames(): raise tests.TestNotApplicable('OSX normalizes filenames') tree = self.make_branch_and_tree('.') self.build_tree(['a']) tree.add(['a']) self.assertRaises((errors.InvalidNormalization, UnicodeEncodeError), tree.rename_one, 'a', u'ba\u030arry')