Ejemplo n.º 1
0
    def tearDown(self):
        # Cleanup opened resources after a test. This is usually done through atexit handlers in
        # Certbot, but during tests, atexit will not run registered functions before tearDown is
        # called and instead will run them right before the entire test process exits.
        # It is a problem on Windows, that does not accept to clean resources before closing them.
        util._release_locks()  # pylint: disable=protected-access

        shutil.rmtree(self.temp_dir)
        shutil.rmtree(self.config_dir)
        shutil.rmtree(self.work_dir)
        shutil.rmtree(self.logs_dir)
Ejemplo n.º 2
0
    def tearDown(self):
        """Execute after test"""
        # Cleanup opened resources after a test. This is usually done through atexit handlers in
        # Certbot, but during tests, atexit will not run registered functions before tearDown is
        # called and instead will run them right before the entire test process exits.
        # It is a problem on Windows, that does not accept to clean resources before closing them.
        logging.shutdown()
        # Remove logging handlers that have been closed so they won't be
        # accidentally used in future tests.
        logging.getLogger().handlers = []
        util._release_locks()  # pylint: disable=protected-access

        shutil.rmtree(self.tempdir)
Ejemplo n.º 3
0
    def tearDown(self):
        """Execute after test"""
        # Cleanup opened resources after a test. This is usually done through atexit handlers in
        # Certbot, but during tests, atexit will not run registered functions before tearDown is
        # called and instead will run them right before the entire test process exits.
        # It is a problem on Windows, that does not accept to clean resources before closing them.
        logging.shutdown()
        util._release_locks()  # pylint: disable=protected-access

        def handle_rw_files(_, path, __):
            """Handle read-only files, that will fail to be removed on Windows."""
            os.chmod(path, stat.S_IWRITE)
            os.remove(path)

        shutil.rmtree(self.tempdir, onerror=handle_rw_files)
Ejemplo n.º 4
0
    def tearDown(self):
        """Execute after test"""
        # Cleanup opened resources after a test. This is usually done through atexit handlers in
        # Certbot, but during tests, atexit will not run registered functions before tearDown is
        # called and instead will run them right before the entire test process exits.
        # It is a problem on Windows, that does not accept to clean resources before closing them.
        logging.shutdown()
        # Remove logging handlers that have been closed so they won't be
        # accidentally used in future tests.
        logging.getLogger().handlers = []
        util._release_locks()  # pylint: disable=protected-access

        def handle_rw_files(_, path, __):
            """Handle read-only files, that will fail to be removed on Windows."""
            os.chmod(path, stat.S_IWRITE)
            os.remove(path)
        shutil.rmtree(self.tempdir, onerror=handle_rw_files)
Ejemplo n.º 5
0
    def tearDown(self):
        """Execute after test"""
        # Cleanup opened resources after a test. This is usually done through atexit handlers in
        # Certbot, but during tests, atexit will not run registered functions before tearDown is
        # called and instead will run them right before the entire test process exits.
        # It is a problem on Windows, that does not accept to clean resources before closing them.
        logging.shutdown()
        # Remove logging handlers that have been closed so they won't be
        # accidentally used in future tests.
        logging.getLogger().handlers = []
        util._release_locks()  # pylint: disable=protected-access

        def handle_rw_files(_, path, __):
            """Handle read-only files, that will fail to be removed on Windows."""
            filesystem.chmod(path, stat.S_IWRITE)
            try:
                os.remove(path)
            except (IOError, OSError):
                # TODO: remote the try/except once all logic from windows file permissions is merged
                if os.name != 'nt':
                    raise

        shutil.rmtree(self.tempdir, onerror=handle_rw_files)