Beispiel #1
0
    def load_project(self, root, Model, testdir=get_setting('StartDir')):
        self.Model = Model
        project = None
        while project is None:
            try:
                # Create the project objects
                project = Model()

                disc = Discover()
                test_list = disc.collect_tests(testdir)

                errors = []

                project.refresh(test_list, errors)
            except ModelLoadError as e:
                # Load failed; destroy the project and show an error dialog.
                # If the user selects cancel, quit.
                project = None
                dialog = TestLoadErrorDialog(root, e.trace)
                if dialog.status == dialog.CANCEL:
                    sys.exit(1)
        if project.errors:
            dialog = IgnorableTestLoadErrorDialog(root, '\n'.join(project.errors))
            if dialog.status == dialog.CANCEL:
                sys.exit(1)

        return project
Beispiel #2
0
    def reload_project(self, testdir=get_setting('StartDir')):
        # If the directory does not exist, throw an error message and don't do anything.
        if os.path.exists(testdir) is False:
            dialog = tkMessageBox.showerror
            dialog(message='Directory: ' + testdir + ' does not exist!')
            return

        self._reset_all_tests_tree()
        self._reset_problem_tests_tree()

        self.project = self.load_project(self.root, self.Model, testdir)
Beispiel #3
0
                        if specified == module_name:
                            suite.addTest(test)

            # Add all tests in a class within a file.
            for specified in self.specified_list:
                if specified.count('.') == 1:
                    for test in flat_tests:
                        module_name = test.id()[0:test.id().rindex('.')]
                        if specified == module_name:
                            suite.addTest(test)

            self.stream_suite(suite)

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--testdir', dest='testdir', default=get_setting('StartDir'), help='Directory to choose tests from')
    parser.add_argument('labels', nargs=argparse.REMAINDER, help='Test labels to run.')
    options = parser.parse_args()
    executor = PyTestExecutor()

    # options.labels = list()
    # options.labels.append('test_acquire.TestAcquire.test_print_1')

    if options.labels is not None:
        print('Labels: ', options.labels)


    if options.labels:
        executor.run_only(options.labels)
    executor.stream_results(options.testdir)
Beispiel #4
0
        while input:
            item = input.pop(0)
            try:
                data = iter(item)
                input = list(data) + input
            except:
                yield item

    def collect_tests(self, dirname):
        loader = unittest.TestLoader()
        suite = loader.discover(dirname)
        flatresults = list(self.flatten_results(suite))
        self.tests = [r.id() for r in flatresults]
        return self.tests

    def print_tests(self):
        print('\n'.join(self.tests).strip())


if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--testdir',
                        dest='testdir',
                        default=get_setting('StartDir'),
                        help='Directory to choose tests from')
    options = parser.parse_args()

    disc = Discover()
    disc.collect_tests(options.testdir)
    disc.print_tests()
Beispiel #5
0
 def cmd_load_ip_address(self):
     # Update the instrument IP address.
     update_settings('Host', self.instr_ip_addr.get())
     assert get_setting('Host') == self.instr_ip_addr.get()
Beispiel #6
0
    def _setup_right_frame(self):
        '''
        Right side view output
        '''

        # The right-hand side frame on the main content area
        self.details_frame = Frame(self.content)
        self.details_frame.grid(column=0, row=0, sticky=(N, S, E, W))
        self.content.add(self.details_frame)

        # Add support instrument IP Address.
        self.instrument_ip_address_label = Label(self.details_frame, text = "Meta Data")
        # self.instrument_ip_address_label.grid(column=0, row=0, sticky=(W))

        self.instr_ip_addr = StringVar()
        self.instr_ip_addr_widget = Entry(self.details_frame, textvariable= self.instr_ip_addr, width=60)
        self.instr_ip_addr.set(get_setting('Host') or 'Not Found')
        # self.instr_ip_addr_widget.grid(column=1, row=0, sticky=(W))

        self.reload_ip_address = Button(self.details_frame, text='Update Meta', command=self.cmd_load_ip_address)
        # self.reload_ip_address.grid(column=1, row=0, sticky=(E))

        # Add label for test directory
        self.testdir_label = Label(self.details_frame, text="Test Directory:")
        self.testdir_label.grid(column=0, row=1, sticky=(W))

        self.testdir_name = StringVar()
        self.testdir_widget = Entry(self.details_frame, textvariable= self.testdir_name, width=40)
        self.testdir_name.set(get_setting('StartDir'))
        self.testdir_widget.grid(column=1, row=1, sticky=(W))

        # Reload Tests Load Button.
        self.reload_tests_button = Button(self.details_frame, text='Reload Tests', command=self.cmd_reload_tests)
        self.reload_tests_button.grid(column=1, row=1, sticky=(E))

        # Test Name
        self.name_label = Label(self.details_frame, text='Name:')
        self.name_label.grid(column=0, row=2, pady=5, sticky=(E))

        self.name = StringVar()
        self.name_widget = Entry(self.details_frame, textvariable=self.name)
        self.name_widget.configure(state='readonly')
        self.name_widget.grid(column=1, row=2, pady=5, sticky=(W, E))

        # Test status
        self.test_status = StringVar()
        self.test_status_widget = Label(self.details_frame, textvariable=self.test_status, width=5, anchor=CENTER)
        f = Font(font=self.test_status_widget['font'])
        f['weight'] = 'bold'
        f['size'] = 40
        self.test_status_widget.config(font=f)
        self.test_status_widget.grid(column=2, row=2, padx=2, pady=2, rowspan=2, sticky=(N, W))

        # Test duration
        self.duration_label = Label(self.details_frame, text='Duration:')
        self.duration_label.grid(column=0, row=3, pady=5, sticky=(E,))

        self.duration = StringVar()
        self.duration_widget = Entry(self.details_frame, textvariable=self.duration)
        self.duration_widget.grid(column=1, row=3, pady=5, sticky=(E, W,))

        # Test description
        self.description_label = Label(self.details_frame, text='Description:')
        self.description_label.grid(column=0, row=3, pady=5, sticky=(N, E,))

        self.description = ReadOnlyText(self.details_frame, width=80, height=4)
        self.description.grid(column=1, row=4, pady=5, columnspan=2, sticky=(N, S, E, W,))

        self.description_scrollbar = Scrollbar(self.details_frame, orient=VERTICAL)
        self.description_scrollbar.grid(column=3, row=4, pady=5, sticky=(N, S))
        self.description.config(yscrollcommand=self.description_scrollbar.set)
        self.description_scrollbar.config(command=self.description.yview)

        # Test output
        self.output_label = Label(self.details_frame, text='Output:')
        self.output_label.grid(column=0, row=5, pady=5, sticky=(N, E,))

        self.output = ReadOnlyText(self.details_frame, width=80, height=10)
        self.output.grid(column=1, row=5, pady=5, columnspan=2, sticky=(N, S, E, W,))

        self.output_scrollbar = Scrollbar(self.details_frame, orient=VERTICAL)
        self.output_scrollbar.grid(column=3, row=5, pady=5, sticky=(N, S))
        self.output.config(yscrollcommand=self.output_scrollbar.set)
        self.output_scrollbar.config(command=self.output.yview)

        # Error message
        self.error_label = Label(self.details_frame, text='Error:')
        self.error_label.grid(column=0, row=6, pady=5, sticky=(N, E,))

        self.error = ReadOnlyText(self.details_frame, width=80)
        self.error.grid(column=1, row=6, pady=5, columnspan=2, sticky=(N, S, E, W))

        self.error_scrollbar = Scrollbar(self.details_frame, orient=VERTICAL)
        self.error_scrollbar.grid(column=3, row=6, pady=5, sticky=(N, S))
        self.error.config(yscrollcommand=self.error_scrollbar.set)
        self.error_scrollbar.config(command=self.error.yview)

        # Set up GUI weights for the details frame
        self.details_frame.columnconfigure(0, weight=0)
        self.details_frame.columnconfigure(1, weight=1)
        self.details_frame.columnconfigure(2, weight=0)
        self.details_frame.columnconfigure(3, weight=0)
        self.details_frame.columnconfigure(4, weight=0)
        self.details_frame.rowconfigure(0, weight=1)
        self.details_frame.rowconfigure(1, weight=1)
        self.details_frame.rowconfigure(2, weight=0)
        self.details_frame.rowconfigure(3, weight=0)
        self.details_frame.rowconfigure(4, weight=1)
        self.details_frame.rowconfigure(5, weight=5)
        self.details_frame.rowconfigure(6, weight=10)