# Buggy code
def get_subpaths(self, basepath):
    """Returns direct subpaths for this object, i.e. either the named subfolder or all
    subfolders matching the pattern"""
    if isinstance(self.pattern, re._pattern_type):
        return (
            os.path.join(basepath, p)
            for p in os.listdir(basepath)
            if self.pattern.match(p) and os.path.isdir(os.path.join(basepath, p))
        )
    else:
        path = os.path.join(basepath, self.pattern)
        return [path] if os.path.isdir(path) else []


# 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_subpaths(self, basepath):
    """Returns direct subpaths for this object, i.e. either the named subfolder or all
    subfolders matching the pattern"""
    if isinstance(self.pattern, Pattern):
        return (
            os.path.join(basepath, p)
            for p in os.listdir(basepath)
            if self.pattern.match(p) and os.path.isdir(os.path.join(basepath, p))
        )
    else:
        path = os.path.join(basepath, self.pattern)
        return [path] if os.path.isdir(path) else []