def test_split_ext(self): normal = ['a.b.c.d.pdf', '.bashrc', '.a.conf', '/a/b/c/a2.cpp', 'a.xml', 'aaaaa...avi', '/a-b.png', '_ab_123.jpg', 'abc.tar', 'my_file'] for name in normal: their = os.path.splitext(name) ours = split_extension(name) self.assertEqual(ours, their) weird = ['test.tar.gz', 'test.tar.xz', '/a/b/c/test.tar.bz2'] for name in weird: self.assertNotIn('.', split_extension(name)[0])
def download_name(self): ext = split_extension(self.package_file.name)[1] if self.problem: return self.problem.short_name + ext else: filename = os.path.split(self.package_file.name)[1] return strip_num_or_hash(filename)