Esempio n. 1
0
 def configure(self, options, config):
     super(FreshenNosePlugin, self).configure(options, config)
     all_tags = options.tags.split(",") if options.tags else []
     self.tagmatcher = TagMatcher(all_tags)
     self.language = load_language(options.language)
     self.impl_loader = StepImplLoader()
     if not self.language:
         print >> sys.stderr, "Error: language '%s' not available" % options.language
         exit(1)
Esempio n. 2
0
 def configure(self, options, config):
     super(FreshenNosePlugin, self).configure(options, config)
     all_tags = options.tags.split(",") if options.tags else []
     self.tagmatcher = TagMatcher(all_tags)
     self.language = load_language(options.language)
     self.impl_loader = StepImplLoader()
     if not self.language:
         print >> sys.stderr, "Error: language '%s' not available" % options.language
         exit(1)
Esempio n. 3
0
class FreshenNosePlugin(Plugin):
    
    name = "freshen"
    
    def options(self, parser, env):
        super(FreshenNosePlugin, self).options(parser, env)
        
        parser.add_option('--tags', action='store',
                          dest='tags',
                          default=env.get('NOSE_FRESHEN_TAGS'),
                          help="Run only those scenarios and features which "
                               "match the given tags. Should be a comma-separated "
                               "list. Each tag can be prefixed with a ~ to negate "
                               "[NOSE_FRESHEN_TAGS]")
        parser.add_option('--language', action="store", dest='language',
            default='en',
            help='Change the language used when reading the feature files',
        )

    def configure(self, options, config):
        super(FreshenNosePlugin, self).configure(options, config)
        all_tags = options.tags.split(",") if options.tags else []
        self.tagmatcher = TagMatcher(all_tags)
        self.language = load_language(options.language)
        self.impl_loader = StepImplLoader()
        if not self.language:
            print >> sys.stderr, "Error: language '%s' not available" % options.language
            exit(1)
    
    def wantDirectory(self, dirname):
        if not os.path.exists(os.path.join(dirname, ".freshenignore")):
            return True
        return None
    
    def wantFile(self, filename):
        return filename.endswith(".feature") or None
    
    def loadTestsFromFile(self, filename, indexes=[]):
        if self.wantFile( filename ):
            log.debug("Loading from file %s" % filename)
            
            step_registry = StepImplRegistry(TagMatcher)
            try:
                feat = load_feature(filename, self.language)
                path = os.path.dirname(filename)
                self.impl_loader.load_steps_impl(step_registry, path, feat.use_step_defs)
            except ParseException, e:
                ec, ev, tb = sys.exc_info()
                yield Failure(ParseException, ParseException(e.pstr, e.loc, e.msg + " in %s" % filename), tb)
                return
            
            cnt = 0
            ctx = FeatureSuite()
            for i, sc in enumerate(feat.iter_scenarios()):
                if (not indexes or (i + 1) in indexes):
                    if self.tagmatcher.check_match(sc.tags + feat.tags):
                        yield FreshenTestCase(StepsRunner(step_registry), step_registry, feat, sc, ctx)
                        cnt += 1
            
            if not cnt:
                yield False
        else: