Exemplo n.º 1
0
    def show_test_selection(self):
        """
        Show the currently selected tests in the current project.
        Add or remove tests using the
        add_tests and remove_tests commands respectively.
        """
        ids_list = list(self.test_set)
        tests = []
        for file_object in self.project.get_tests():
            file_name = os.path.basename(file_object.path)
            print(term.yellow(file_name))
            for test_group in file_object.testsuite:
                for testId, test in enumerate(test_group):
                    if testId == 0:
                        groupName = str(test.__class__.__name__)
                    testName = test.id().split('.')[-1]
                    tests.append((file_name, groupName, testName, test))

        # Filter out any invalid indices
        ids_list = list(filter(lambda x: x < len(tests), ids_list))
        for idx, (fileName, groupName, testName, test) in enumerate(
            [tests[idx] for idx in ids_list]
        ):
            print(
                '{:<5}'.format(str(ids_list[idx]) + ':') +
                '[' + term.yellow(fileName) + ']' +
                '[' + term.green(groupName) + ']' +
                '[' + term.blue(testName) + ']'
            )
Exemplo n.º 2
0
    def show_test_selection(self):
        """
        Show the currently selected tests in the current project.
        Add or remove tests using the
        add_tests and remove_tests commands respectively.
        """
        ids_list = list(self.test_set)
        tests = []
        for file_object in self.project.get_tests():
            file_name = os.path.basename(file_object.path)
            print(term.yellow(file_name))
            for test_group in file_object.testsuite:
                for testId, test in enumerate(test_group):
                    if testId == 0:
                        groupName = str(test.__class__.__name__)
                    testName = test.id().split('.')[-1]
                    tests.append((file_name, groupName, testName, test))

        # Filter out any invalid indices
        ids_list = list(filter(lambda x: x < len(tests), ids_list))
        for idx, (fileName, groupName, testName,
                  test) in enumerate([tests[idx] for idx in ids_list]):
            print('{:<5}'.format(str(ids_list[idx]) + ':') + '[' +
                  term.yellow(fileName) + ']' + '[' + term.green(groupName) +
                  ']' + '[' + term.blue(testName) + ']')
Exemplo n.º 3
0
    def do_show_tests(self, command):
        """
        Show the tests available in the current project.
        """
        tests = self.project.get_tests()

        if len(tests) == 0:
            log.info('There are no tests available.')
            return

        testUniqueId = 0
        for file_object in tests:
            file_name = os.path.basename(file_object.path)
            print(term.yellow(file_name))
            for test_group in file_object.testsuite:
                for testId, test in enumerate(test_group):
                    if testId == 0:
                        print(
                            SEP + term.green(str(test.__class__.__name__))
                        )
                    doc = test.shortDescription()
                    if doc is None:
                        doc = term.darkred('No description')
                    if testUniqueId in self.test_set:
                        msg = SEP * 2 + '[' + term.blue('ID ' + str(
                            testUniqueId) + ' ' + test.id().split('.')[-1]
                        ) + ']'
                    else:
                        msg = SEP * 2 + term.lightgray('ID ' + str(
                            testUniqueId) + ' ' + test.id().split('.')[-1]
                        )
                    print(msg)
                    print(term.darkgray(textwrap.fill(
                        doc,
                        width=80,
                        initial_indent=SEP * 2,
                        subsequent_indent=SEP * 2,
                    )))
                    testUniqueId += 1
Exemplo n.º 4
0
    def do_show_tests(self, command):
        """
        Show the tests available in the current project.
        """
        tests = self.project.get_tests()

        if len(tests) == 0:
            log.info('There are no tests available.')
            return

        testUniqueId = 0
        for file_object in tests:
            file_name = os.path.basename(file_object.path)
            print(term.yellow(file_name))
            for test_group in file_object.testsuite:
                for testId, test in enumerate(utils.iterate_tests(test_group)):
                    if testId == 0:
                        print(
                            SEP + term.green(str(test.__class__.__name__))
                        )
                    doc = test.shortDescription()
                    if doc is None:
                        doc = term.darkred('No description')
                    if testUniqueId in self.test_set:
                        msg = SEP * 2 + '[' + term.blue('ID ' + str(
                            testUniqueId) + ' ' + test.id().split('.')[-1]
                        ) + ']'
                    else:
                        msg = SEP * 2 + term.lightgray('ID ' + str(
                            testUniqueId) + ' ' + test.id().split('.')[-1]
                        )
                    print(msg)
                    print(term.darkgray(textwrap.fill(
                        doc,
                        width=80,
                        initial_indent=SEP * 2,
                        subsequent_indent=SEP * 2,
                    )))
                    testUniqueId += 1