MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / test_fakelocalizationdirs

Method test_fakelocalizationdirs

tests/TestUnix.py:580–623  ·  view source on GitHub ↗

Create a faked localization hierarchy and clean it afterwards

(self)

Source from the content-addressed store, hash-verified

578
579 @common.skipIfWindows
580 def test_fakelocalizationdirs(self):
581 """Create a faked localization hierarchy and clean it afterwards"""
582
583 keepdirs = [
584 'important_dontdelete',
585 'important_dontdelete/ru',
586 'delete',
587 'delete/locale',
588 'delete/locale/en',
589 'delete/dummyfiles',
590 'foobar',
591 'foobar/locale']
592 nukedirs = [
593 'delete/locale/ru',
594 'foobar/locale/ru']
595 keepfiles = [
596 'delete/dummyfiles/dontdeleteme_ru.txt',
597 'important_dontdelete/exceptthisone_ru.txt',
598 'delete/dummyfiles/en.txt',
599 'delete/dummyfiles/ru.dic']
600 nukefiles = [
601 'delete/dummyfiles/ru.txt',
602 'delete/locale/ru_RU.UTF8.txt']
603 for path in keepdirs + nukedirs:
604 os.mkdir(os.path.join(self.tempdir, path))
605 for path in keepfiles + nukefiles:
606 self.write_file(path)
607
608 configxml = '<path directoryregex="^.*$">' \
609 ' <path directoryregex="^(locale|dummyfiles)$">' \
610 ' <path location="." filter="*" />' \
611 r' <regexfilter postfix="\.txt" />' \
612 ' </path>' \
613 '</path>'
614 config = parseString(configxml)
615 self.locales._paths = LocaleCleanerPath(self.tempdir)
616 self.locales.add_xml(config.firstChild, None)
617 # normpath because paths may contain ./
618 deletelist = [os.path.normpath(
619 path) for path in self.locales.localization_paths(['en', 'de'])]
620 for path in keepdirs + keepfiles:
621 self.assertNotIn(os.path.join(self.tempdir, path), deletelist)
622 for path in nukedirs + nukefiles:
623 self.assertIn(os.path.join(self.tempdir, path), deletelist)
624
625 @common.skipIfWindows
626 def test_rotated_logs_real(self):

Callers

nothing calls this directly

Calls 6

LocaleCleanerPathClass · 0.90
mkdirMethod · 0.80
joinMethod · 0.80
write_fileMethod · 0.80
add_xmlMethod · 0.80
localization_pathsMethod · 0.80

Tested by

no test coverage detected