def setUp(self):  # suppress(N802)
        """Create executable python file in temp dir and add it to PATH."""
        super(TestJobstampMain, self).setUp()
        self._executable_file = os.path.join(os.getcwd(), "executable")
        with open(self._executable_file, "w"):
            pass

        os.chmod(self._executable_file,
                 os.stat(self._executable_file).st_mode |
                 stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)

        last_path = os.environ["PATH"]
        os.environ["PATH"] = os.environ["PATH"] + os.pathsep + os.getcwd()

        self.addCleanup(lambda: os.environ.update({"PATH": last_path}))

        # Unset the JOBSTAMPS_ALWAYS_USE_HASHES variable if it is
        # set and add a cleanup task to re-set it later. We don't want to
        # keep that variable during tests because it will the
        # mtime code paths to remain untested.
        always_use_hashes_var = "JOBSTAMPS_ALWAYS_USE_HASHES"
        testutil.temporarily_clear_variable_on_testsuite(self,
                                                         always_use_hashes_var)
Пример #2
0
 def setUp(self):  # suppress(invalid-name)
     """Clear the JOBSTAMPS_ALWAYS_USE_HASHES variable before each test."""
     super(TestJobstamps, self).setUp()
     always_use_hashes_var = "JOBSTAMPS_ALWAYS_USE_HASHES"
     testutil.temporarily_clear_variable_on_testsuite(self, always_use_hashes_var)
     testutil.temporarily_clear_variable_on_testsuite(self, "JOBSTAMPS_DISABLED")