示例#1
0
    def testUpdate(self):
        # replace counter with new one
        self.current_count = 0
        def update(val):
            self.current_count = val
        self.counter = util.counter(TestCounter.MAX_VALUE, update)
        self.assertEqual(0, self.current_count)

        self.counter.increment()
        self.assertEqual(1, self.current_count)
示例#2
0
    efg_file = cfg.get('general', 'efg_file')
    log.info('loading efg file %s' % efg_file)
    gr = parser.load(efg_file)

    try:
        pkg, class_ = cfg.get('testgenerator', 'plugin').rsplit('.', 1)
        testgenerator = getattr(__import__(pkg, fromlist=[class_]), class_)()
    except (ImportError, AttributeError), e:
        log.exception(e)
        return 1

    testgenerator.add_options(cfg)

    max = float(cfg.get('testgenerator', 'max'))
    progress = util.ProgressBar(max)
    counter = util.counter(max, progress.update)
    start_nodes = [x for x in gr if 'start_node' in gr.node_attributes(x)]
    tests = testgenerator.generate(gr, start_nodes, cfg, counter)

    # Write each one of these tests to a separate test file
    print 'writing test files to disk'
    progress = util.ProgressBar(len(tests))
    output_dir = cfg.get('testgenerator', 'folder')
    if not os.path.exists(output_dir):
        log.debug('creating folder %s' % os.path.abspath(output_dir))
        os.makedirs(output_dir)

    format = cfg.get('testgenerator', 'format')
    for i, t in enumerate(tests):
        name = 't_%s.%s' % ('_'.join(['e%u' % hash(m) for m in t]), format)
        file_ = os.path.join(output_dir, name)
示例#3
0
 def setUp(self):
     self.counter = util.counter(TestCounter.MAX_VALUE)