# Buggy code
def get_localizations(self, basepath):
    """Returns all localization items for this object and all descendant objects"""
    for path in self.get_subpaths(basepath):
        for child in self.children:
            if isinstance(child, LocaleCleanerPath):
                for res in child.get_localizations(path):
                    yield res
            elif isinstance(child, re._pattern_type):
                for element in os.listdir(path):
                    match = child.match(element)
                    if match is not None:
                        yield (
                            match.group("locale"),
                            match.group("specifier"),
                            os.path.join(path, element),
                        )


# Traceback (AssertionError)
======================================================================
FAIL: test_whitelisted_posix_symlink (tests.TestFileUtilities.FileUtilitiesTestCase)
Symlink test for whitelisted_posix()
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/bleachbit/tests/common.py", line 160, in wrapper
return f(*args, **kwargs)
File "/tmp/bleachbit/tests/TestFileUtilities.py", line 792, in test_whitelisted_posix_symlink
realpath = self.write_file('real')
File "/tmp/bleachbit/tests/common.py", line 116, in write_file
assert (os.path.exists(extended_path(filename)))
AssertionError

======================================================================
FAIL: test_wipe_contents (tests.TestFileUtilities.FileUtilitiesTestCase)
Unit test for wipe_delete()
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/bleachbit/tests/TestFileUtilities.py", line 844, in test_wipe_contents
filename = self.write_file('bleachbit-test-wipe', b'abcdefghij' * 12345)
File "/tmp/bleachbit/tests/common.py", line 116, in write_file
assert (os.path.exists(extended_path(filename)))
AssertionError

======================================================================
FAIL: test_wipe_name (tests.TestFileUtilities.FileUtilitiesTestCase)
Unit test for wipe_name()
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/bleachbit/tests/TestFileUtilities.py", line 880, in test_wipe_name
filename = self.write_file('bleachbit-test-wipe' + '0' * 50)
File "/tmp/bleachbit/tests/common.py", line 116, in write_file
assert (os.path.exists(extended_path(filename)))
AssertionError

======================================================================
FAIL: test_fakelocalizationdirs (tests.TestUnix.UnixTestCase)
Create a faked localization hierarchy and clean it afterwards
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/bleachbit/tests/common.py", line 160, in wrapper
return f(*args, **kwargs)
File "/tmp/bleachbit/tests/TestUnix.py", line 185, in test_fakelocalizationdirs
self.write_file(path)
File "/tmp/bleachbit/tests/common.py", line 116, in write_file
assert (os.path.exists(extended_path(filename)))
AssertionError

======================================================================
FAIL: test_is_running (tests.TestUnix.UnixTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/bleachbit/tests/common.py", line 160, in wrapper
return f(*args, **kwargs)
File "/tmp/bleachbit/tests/TestUnix.py", line 105, in test_is_running
self.assertTrue(is_running(exe))
AssertionError: False is not true

======================================================================
FAIL: test_many_patterns (tests.TestWinapp.WinappTestCase)
Test a cleaner like Steam Installers and related performance improvement
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/bleachbit/tests/TestWinapp.py", line 439, in test_many_patterns
common.touch_file(tmp_fn)
File "/tmp/bleachbit/tests/common.py", line 182, in touch_file
assert(os.path.exists(filename))
AssertionError

----------------------------------------------------------------------
Ran 167 tests in 74.622s

FAILED (failures=21, errors=39, skipped=26)
make: *** [Makefile:107: tests] Error 1

# Fixed code
def get_localizations(self, basepath):
    """Returns all localization items for this object and all descendant objects"""
    for path in self.get_subpaths(basepath):
        for child in self.children:
            if isinstance(child, LocaleCleanerPath):
                for res in child.get_localizations(path):
                    yield res
            elif isinstance(child, Pattern):
                for element in os.listdir(path):
                    match = child.match(element)
                    if match is not None:
                        yield (
                            match.group("locale"),
                            match.group("specifier"),
                            os.path.join(path, element),
                        )