Esempio n. 1
0
    def __call__(self):
        """Execute the test from the run.py file.

        """
        if _TEST_NAME_FILE:
            f = open(_TEST_NAME_FILE, "w")
            f.write(self.description.replace("/", "_"))
            f.close()

        cwd = self.cd(self.dir)

        # Prepare a dictionary of globals for the run.py files to use.
        fns = """
            copy run runfunc compare contains doesnt_contain clean skip
            """.split()
        if self.clean_only:
            glo = dict((fn, self.noop) for fn in fns)
            glo["clean"] = self.clean
        else:
            glo = dict((fn, getattr(self, fn)) for fn in fns)
            if self.dont_clean:  # pragma: not covered
                glo["clean"] = self.noop

        old_mods = dict(sys.modules)
        try:
            execfile(self.runpy, glo)
        finally:
            self.cd(cwd)
            # Remove any new modules imported during the test run. This lets us
            # import the same source files for more than one test.
            to_del = [m for m in sys.modules if m not in old_mods]
            for m in to_del:
                del sys.modules[m]
Esempio n. 2
0
    def __call__(self):
        """Execute the test from the run.py file."""
        if _TEST_NAME_FILE:                             # pragma: debugging
            with open(_TEST_NAME_FILE, "w") as f:
                f.write(self.description.replace("/", "_"))

        # Prepare a dictionary of globals for the run.py files to use.
        fns = """
            copy run clean skip
            compare contains contains_any doesnt_contain
            """.split()
        if self.clean_only:
            glo = dict((fn, noop) for fn in fns)
            glo['clean'] = clean
        else:
            glo = dict((fn, globals()[fn]) for fn in fns)
            if self.dont_clean:                 # pragma: debugging
                glo['clean'] = noop

        with change_dir(self.dir):
            try:
                execfile(self.runpy, glo)
            except Exception:
                self.ok = False
                raise
Esempio n. 3
0
    def __call__(self):
        """Execute the test from the run.py file.

        """
        if _TEST_NAME_FILE:
            f = open(_TEST_NAME_FILE, "w")
            f.write(self.description.replace("/", "_"))
            f.close()

        cwd = self.cd(self.dir)

        # Prepare a dictionary of globals for the run.py files to use.
        fns = """
            copy run runfunc compare contains doesnt_contain clean skip
            """.split()
        if self.clean_only:
            glo = dict([(fn, self.noop) for fn in fns])
            glo['clean'] = self.clean
        else:
            glo = dict([(fn, getattr(self, fn)) for fn in fns])
            if self.dont_clean:                 # pragma: not covered
                glo['clean'] = self.noop

        old_mods = dict(sys.modules)
        try:
            execfile(self.runpy, glo)
        finally:
            self.cd(cwd)
            # Remove any new modules imported during the test run. This lets us
            # import the same source files for more than one test.
            to_del = [m for m in sys.modules if m not in old_mods]
            for m in to_del:
                del sys.modules[m]
Esempio n. 4
0
    def __call__(self):
        """Execute the test from the run.py file."""
        if _TEST_NAME_FILE:                                 # pragma: debugging
            with open(_TEST_NAME_FILE, "w") as f:
                f.write(self.description.replace("/", "_"))

        # Prepare a dictionary of globals for the run.py files to use.
        fns = """
            copy run runfunc clean skip
            compare contains contains_any doesnt_contain
            """.split()
        if self.clean_only:
            glo = dict((fn, noop) for fn in fns)
            glo['clean'] = clean
        else:
            glo = dict((fn, globals()[fn]) for fn in fns)
            if self.dont_clean:                 # pragma: not covered
                glo['clean'] = noop

        with change_dir(self.dir):
            try:
                execfile(self.runpy, glo)
            except Exception:
                self.ok = False
                raise
Esempio n. 5
0
    def __call__(self):  # pylint: disable=arguments-differ
        """Execute the test from the runpy file."""
        # Prepare a dictionary of globals for the run.py files to use.
        fns = """
            copy run clean skip
            compare contains contains_any doesnt_contain
            """.split()
        if self.clean_only:
            glo = dict((fn, noop) for fn in fns)
            glo['clean'] = clean
        else:
            glo = dict((fn, globals()[fn]) for fn in fns)
            if self.dont_clean:  # pragma: debugging
                glo['clean'] = noop

        with change_dir(self.dir):
            try:
                execfile(self.runpy, glo)
            except Exception:
                self.ok = False
                raise