Esempio n. 1
0
    def test_path(self):
        """Test the ScannerBase path() method"""
        def pf(env, cwd, target, source, argument=None):
            return "pf: %s %s %s %s %s" % \
                        (env.VARIABLE, cwd, target[0], source[0], argument)

        env = DummyEnvironment()
        env.VARIABLE = 'v1'
        target = DummyNode('target')
        source = DummyNode('source')

        s = ScannerBase(self.func, path_function=pf)
        p = s.path(env, 'here', [target], [source])
        assert p == "pf: v1 here target source None", p

        s = ScannerBase(self.func, path_function=pf, argument="xyz")
        p = s.path(env, 'here', [target], [source])
        assert p == "pf: v1 here target source xyz", p
Esempio n. 2
0
    def test_scan_check(self):
        """Test the ScannerBase class scan_check() method"""
        def my_scan(filename, env, target, *args):
            return []

        def check(node, env, s=self):
            s.checked[str(node)] = 1
            return 1

        env = DummyEnvironment()
        s = ScannerBase(my_scan, "Check", scan_check=check)
        self.checked = {}
        path = s.path(env)
        scanned = s(DummyNode('x'), env, path)
        self.assertTrue(self.checked['x'] == 1, "did not call check function")