Skip to content

Commit

Permalink
Utility: Fix doctest execution on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
sanssecours committed Oct 18, 2023
1 parent 91ac3c2 commit ed8a106
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions mytoolit/utility/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,29 @@ def get_log_file_handler(filename: str) -> FileHandler:
Example
-------
Init the logger
Initialize test data
>>> from logging import getLogger
>>> from platform import system
>>> from re import match
>>> logger = getLogger("test")
>>> logger.addHandler(get_log_file_handler("test.log"))
>>> from sys import platform
>>> filename = "test.log"
>>> log_filepath = user_log_path(
... appname=ConfigurationUtility.app_name,
... appauthor=ConfigurationUtility.app_author) / filename
Workaround for missing support to remove files while “in use” on Windows
(aka “The process cannot access the file because it is being used by
another process”)
>>> if system() == "Windows":
... log_filepath.unlink(missing_ok=True)
Initialize logger
>>> logger = getLogger()
>>> logger.addHandler(get_log_file_handler(filename))
The log file should not exist until we add something to it
Expand All @@ -55,7 +72,8 @@ def get_log_file_handler(filename: str) -> FileHandler:
Remove test log file
>>> log_filepath.unlink()
>>> if system() != "Windows":
... log_filepath.unlink()
"""

Expand Down

0 comments on commit ed8a106

Please sign in to comment.