mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 03:11:55 +02:00
This PR is the first part of #6497 to ease the integration, following the new plan propose by @bmw here: #6497 (comment) This step 1 refactor existing certbot.compat module into certbot.compat.misc, without any logic changed. Package certbot.compat will host the new modules that constitute the security model for Windows. * Create the certbot.compat package. Move logic in certbot.compat.misc * Add doc * Fix lint * Correct mypy * Update client.py
23 lines
740 B
Python
23 lines
740 B
Python
"""Tests for certbot.compat."""
|
|
import os
|
|
|
|
import certbot.tests.util as test_util
|
|
from certbot.compat import misc
|
|
|
|
|
|
class OsReplaceTest(test_util.TempDirTestCase):
|
|
"""Test to ensure consistent behavior of os_rename method"""
|
|
|
|
def test_os_rename_to_existing_file(self):
|
|
"""Ensure that os_rename will effectively rename src into dst for all platforms."""
|
|
src = os.path.join(self.tempdir, 'src')
|
|
dst = os.path.join(self.tempdir, 'dst')
|
|
open(src, 'w').close()
|
|
open(dst, 'w').close()
|
|
|
|
# On Windows, a direct call to os.rename will fail because dst already exists.
|
|
misc.os_rename(src, dst)
|
|
|
|
self.assertFalse(os.path.exists(src))
|
|
self.assertTrue(os.path.exists(dst))
|