def _test_pyfile(self, pyfile, want=True, comparator=None, expectexit=False):
        # temporarily redefine the print function in current context
        l = locals()
        l['print'] = lambda x: None
        with open(pyfile) as fp:
            pycode = compile(fp.read(), pyfile, 'exec')
        try:
            result = six.exec_(pycode, globals(), l)
            # the exec:ed code is expected to set return_value
            got = locals()['return_value']
            if not comparator:
                comparator = self.assertEqual
            comparator(want, got)
        except __HOLE__ as e:
            if not expectexit:
                raise e
dataset/ETHPy150Open staffanm/layeredconfig/tests/test_examples.py/Examples._test_pyfile