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

