summaryrefslogtreecommitdiff
path: root/dev-python/loguru/files/0.6.0-py311-fix.patch
blob: a7d29b911fac59e87bce90bee1f0367b67eafb7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Fix failing tests on Python 3.11 (#654)

Issue: https://github.com/Delgan/loguru/issues/654
Commit: https://github.com/Delgan/loguru/commit/5b77724ca75aa8f4b1c8866e0b786c3cbe30ca99

diff --git a/tests/test_filesink_rotation.py b/tests/test_filesink_rotation.py
index bdf75a3..fb80b69 100644
--- a/tests/test_filesink_rotation.py
+++ b/tests/test_filesink_rotation.py
@@ -49,8 +49,8 @@ def monkeypatch_filesystem(monkeypatch):
                     return self._timestamp
                 return getattr(self._wrapped, name)
 
-        def patched_stat(filepath):
-            stat = __stat__(filepath)
+        def patched_stat(filepath, *args, **kwargs):
+            stat = __stat__(filepath, *args, **kwargs)
             wrapped = StatWrapper(stat, filesystem.get(os.path.abspath(filepath)))
             return wrapped
 
diff --git a/tests/test_interception.py b/tests/test_interception.py
index a05802a..2f570b9 100644
--- a/tests/test_interception.py
+++ b/tests/test_interception.py
@@ -1,4 +1,5 @@
 import logging
+import sys
 
 from loguru import logger
 
@@ -7,15 +8,15 @@ from .conftest import make_logging_logger
 
 class InterceptHandler(logging.Handler):
     def emit(self, record):
-        # Get corresponding Loguru level if it exists
+        # Get corresponding Loguru level if it exists.
         try:
             level = logger.level(record.levelname).name
         except ValueError:
             level = record.levelno
 
-        # Find caller from where originated the logged message
-        frame, depth = logging.currentframe(), 2
-        while frame.f_code.co_filename == logging.__file__:
+        # Find caller from where originated the logged message.
+        frame, depth = sys._getframe(6), 6
+        while frame and frame.f_code.co_filename == logging.__file__:
             frame = frame.f_back
             depth += 1
 
@@ -30,7 +31,7 @@ def test_formatting(writer):
 
     expected = (
         "tests.test_interception - test_interception.py - test_formatting - DEBUG - "
-        "10 - 38 - test_interception - This is the message\n"
+        "10 - 39 - test_interception - This is the message\n"
     )
 
     with make_logging_logger("tests", InterceptHandler()) as logging_logger:
@@ -157,4 +158,4 @@ def test_using_logging_function(writer):
         logging.warning("ABC")
 
     result = writer.read()
-    assert result == "test_using_logging_function 157 test_interception test_interception.py ABC\n"
+    assert result == "test_using_logging_function 158 test_interception test_interception.py ABC\n"
-- 
2.39.2