Example #1
0
 def test_from_path(self, path):
     spath = path.split('::')
     if len(spath) == 3:
         return dict(path=spath[0],
                     class_name=tokenizer.valid_class_name(spath[1]),
                     method_name=tokenizer.valid_method_name(spath[2]))
     elif len(spath) == 2:
         return dict(
             path=spath[0],
             class_name=tokenizer.valid_class_name(spath[1]),
         )
     else:
         return dict(path=path)
Example #2
0
 def test_from_path(self, path):
     spath = path.split('::')
     if len(spath) == 3:
         return dict(
                 path        = spath[0],
                 class_name  = tokenizer.valid_class_name(spath[1]),
                 method_name = tokenizer.valid_method_name(spath[2])
                 )
     elif len(spath) == 2:
         return dict(
                 path       = spath[0],
                 class_name = tokenizer.valid_class_name(spath[1]),
                 )
     else:
         return dict(path = path)
Example #3
0
    def parseArgs(self, argv):
        options = ['no-capture', '-s', 'fail', '-x', '-t', '-d', '--debug',
                   'dots', 'traceback', 'tracebacks', 'describe', 'it',
                   '--collect-match', '--collect-ci']
        coverage_options  = ['--show-missing', '--cover-dir', '--cover-report',
                            'cover']
        profiling_options = ['-p', 'profile']
        options.extend(coverage_options)
        options.extend(profiling_options)

        args = ArgOpts(options)
        args.parse_args(argv)
        
        if args.catches_help():
            self.msg(self.konira_help)

        if args.catches_version():
            message = "konira version %s" % __version__
            self.msg(message)

        # Get a valid path
        path_info   = self.path_from_argument(argv)
        search_path = path_info.get('path')
        self.config['class_name']  = path_info.get('class_name')
        self.config['method_name'] = path_info.get('method_name')

        if args.match:

            # Matches for Describe
            if args.has('describe'):
                value = args.get_value('describe')
                if value:
                    self.config['class_name'] = tokenizer.valid_class_name(value)
                else:
                    self.msg("No valid 'describe' name")

            # Matches for it
            if args.has('it'):
                value = args.get_value('it')
                if value:
                    self.config['method_name'] = tokenizer.valid_method_name(value)
                else:
                    self.msg("No valid 'it' name")

            # Collection regex
            if args.has('--collect-match'):
                value = args.get_value('--collect-match')
                if value:
                    self.config['collect-match'] = value
                else:
                    self.msg("'--collect-match' needs a value")

            if args.has('--collect-ci'):
                self.config['collect-ci'] = True

            # Dotted output
            if args.has(['-d','dots']):
                self.config['dotted'] = True

            # Traceback options
            if args.has(['-t', 'traceback']):
                self.config['traceback'] = True

            # Fail options
            if args.has(['-x', 'fail']):
                self.config['first_fail'] = True

            # Capturing options
            if args.has(['-s', 'no-capture']):
                self.config['capturing'] = False

            # Profiling options
            if args.has(['-p', 'profile']):
                self.config['profiling'] = True
                self.config['dotted']    = True

            # Debugging option
            if args.has(['--debug']):
                self.config['debug'] = True

            # Coverage options
            if args.has('cover'):
                self.running_coverage = True
                coverage_options = {}
                value = args.get_value('cover')
                if value:
                    coverage_options['coverpackages'] = [value]
                if args.has('--show-missing'):
                    coverage_options['show_missing'] = True

                run_cover = cover.DoCoverage(coverage_options)


        test_files = FileCollector(search_path, self.config)

        if not test_files:
            self.msg("No cases found to test.")
        try:
            self.capture()
            test_runner = Runner(test_files, self.config)
            test_runner.run()
            self.end_capture()
            report = ReportResults(test_runner)
            report.report()
            if self.running_coverage:
                run_cover.konira_terminal_summary()
            if test_runner.failures or test_runner.errors:
                sys.exit(2)
        except KeyboardInterrupt:
            self.msg("Exiting from konira.")
Example #4
0
    def parseArgs(self, argv):
        options = [
            'no-capture', '-s', 'fail', '-x', '-t', '-d', '--debug', '--pdb',
            'dots', 'traceback', 'tracebacks', 'describe', 'it',
            '--collect-match', '--collect-ci'
        ]
        coverage_options = [
            '--show-missing', '--cover-dir', '--cover-report', 'cover'
        ]
        profiling_options = ['-p', 'profile']
        options.extend(coverage_options)
        options.extend(profiling_options)

        args = ArgOpts(options)
        args.parse_args(argv)

        if args.catches_help():
            self.msg(self.konira_help)

        if args.catches_version():
            message = "konira version %s" % __version__
            self.msg(message)

        # Get a valid path
        path_info = self.path_from_argument(argv)
        search_path = path_info.get('path')
        self.config['class_name'] = path_info.get('class_name')
        self.config['method_name'] = path_info.get('method_name')

        if args.match:

            # Matches for Describe
            if args.has('describe'):
                value = args.get_value('describe')
                if value:
                    self.config['class_name'] = tokenizer.valid_class_name(
                        value)
                else:
                    self.msg("No valid 'describe' name")

            # Matches for it
            if args.has('it'):
                value = args.get_value('it')
                if value:
                    self.config['method_name'] = tokenizer.valid_method_name(
                        value)
                else:
                    self.msg("No valid 'it' name")

            # Collection regex
            if args.has('--collect-match'):
                value = args.get_value('--collect-match')
                if value:
                    self.config['collect-match'] = value
                else:
                    self.msg("'--collect-match' needs a value")

            if args.has('--collect-ci'):
                self.config['collect-ci'] = True

            # Dotted output
            if args.has(['-d', 'dots']):
                self.config['dotted'] = True

            # Traceback options
            if args.has(['-t', 'traceback']):
                self.config['traceback'] = True

            # Fail options
            if args.has(['-x', 'fail']):
                self.config['first_fail'] = True

            # Capturing options
            if args.has(['-s', 'no-capture']):
                self.config['capturing'] = False

            # Profiling options
            if args.has(['-p', 'profile']):
                self.config['profiling'] = True
                self.config['dotted'] = True

            # Debugging option
            if args.has(['--debug']):
                self.config['debug'] = True

            # PDB option
            if args.has(['--pdb']):
                self.config['pdb'] = True

            # PDB on failure option
            if args.has(['--pdb-failure']):
                self.config['pdb_on_fail'] = True

            # Coverage options
            if args.has('cover'):
                self.running_coverage = True
                coverage_options = {}
                value = args.get_value('cover')
                if value:
                    coverage_options['coverpackages'] = [value]
                if args.has('--show-missing'):
                    coverage_options['show_missing'] = True

                run_cover = cover.DoCoverage(coverage_options)

        test_files = FileCollector(search_path, self.config)

        if not test_files:
            self.msg("No cases found to test.")
        try:
            self.capture()
            test_runner = Runner(test_files, self.config)
            test_runner.run()
            self.end_capture()
            report = ReportResults(test_runner)
            report.report()
            if self.running_coverage:
                run_cover.konira_terminal_summary()
            if test_runner.failures or test_runner.errors:
                sys.exit(2)
        except KeyboardInterrupt:
            self.msg("Exiting from konira.")