Example #1
0
 def __init__(self, chain, name, debug, print_times, next_filter=None):
     '''Initialize a filter chain from a list of filters. Decorate them if debugging is on.
     Note: do not call outside this class. Use new_phaser_chain() instead.'''
     FilterChain.__init__(self, [PhaseDecorator(x)
                                 for x in chain] if print_times else chain,
                          name=name,
                          debug=debug,
                          next_filter=next_filter)
Example #2
0
 def test_simple_chain(self):
     '''Check that a chain with printout filters works.'''
     chain = FilterChain(
         [IncrementFilter(1),
          IncrementFilter(2),
          IncrementFilter(3)])
     request = Struct(x=0)
     self.assertFalse(chain.handle(request))
     assert_equal(request.x, 6, 'Bad chain processing')
    def setUp(self):
        '''Load test data and expected results.'''
        unittest.TestCase.setUp(self)

        # Load test data ready from previous phasing stagees
        self.problem = io.read_npz(itu.FAMILY13_STAGE2)
        self.family = self.problem.families()[0]
        self.phaser = phase_core.PhaseDecorator(
            FilterChain([
                trivial_phaser(),
                family_phaser(),
                family_child_comparison_phaser()
            ]))
        self.comparator = ic.ChildComparator(
            Struct(problem=self.problem, params=PhaseParam()), self.family)
Example #4
0
 def test_simple_chain(self):
     '''Check that a chain with printout filters works.'''
     chain = FilterChain([IncrementFilter(1), IncrementFilter(2), IncrementFilter(3)])
     request = Struct(x=0)
     self.assertFalse(chain.handle(request))
     assert_equal(request.x, 6, 'Bad chain processing')
Example #5
0
 def __init__(self, chain, name, debug, print_times, next_filter=None):
     '''Initialize a filter chain from a list of filters. Decorate them if debugging is on.
     Note: do not call outside this class. Use new_phaser_chain() instead.'''
     FilterChain.__init__(self, [PhaseDecorator(x) for x in chain] if print_times else chain,
                          name=name, debug=debug, next_filter=next_filter)