def get_names(cls):
        if cls.NAMES is not None:
            return cls.NAMES

        names = []
        for d in cls.test_directories:
            test_dir = os.path.join(basepath, d)
            for n in os.listdir(test_dir):
                if n.endswith('.py') and not n.startswith('bad'):
                    names.append(os.path.join(test_dir, n))

        # Test limited subset of files unless the 'cpu' resource is specified.
        if not test.support.is_resource_enabled("cpu"):
            names = random.sample(names, 10)
        # bpo-31174: Store the names sample to always test the same files.
        # It prevents false alarms when hunting reference leaks.
        cls.NAMES = names
        return names