Просмотр исходного кода

Fix Windows-specific test failures

Jelmer Vernooij 6 дней назад
Родитель
Сommit
490088a2af
2 измененных файлов с 10 добавлено и 1 удалено
  1. 1 1
      dulwich/porcelain/submodule.py
  2. 9 0
      tests/test_log_utils.py

+ 1 - 1
dulwich/porcelain/submodule.py

@@ -51,7 +51,7 @@ def submodule_add(
 
     with open_repo_closing(repo) as r:
         if path is None:
-            path = os.path.relpath(_canonical_part(url), r.path)
+            path = _canonical_part(url)
         if name is None:
             name = os.fsdecode(path) if path is not None else None
 

+ 9 - 0
tests/test_log_utils.py

@@ -281,6 +281,10 @@ class LogUtilsTests(TestCase):
             self.assertTrue(root_logger.handlers)
             self.assertEqual(root_logger.level, logging.DEBUG)
         finally:
+            # Close all handlers to release file locks (needed on Windows)
+            for handler in root_logger.handlers[:]:
+                handler.close()
+                root_logger.removeHandler(handler)
             if os.path.exists(trace_file):
                 os.unlink(trace_file)
 
@@ -321,6 +325,11 @@ class LogUtilsTests(TestCase):
             root_logger.debug("Test message")
             self.assertTrue(os.path.exists(trace_file))
 
+            # Close all handlers to release file locks (needed on Windows)
+            for handler in root_logger.handlers[:]:
+                handler.close()
+                root_logger.removeHandler(handler)
+
     def test_configure_logging_from_trace_invalid_file(self) -> None:
         """Test _configure_logging_from_trace with invalid file path."""
         from dulwich.log_utils import _configure_logging_from_trace