14
0
forked from pool/python-loguru

- drop python311.patch, loguru-fix-repr-tests.patch: upstream

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-loguru?expand=0&rev=22
This commit is contained in:
2023-05-05 13:41:20 +00:00
committed by Git OBS Bridge
parent 93e22e2824
commit 722a24e8eb
3 changed files with 1 additions and 202 deletions

View File

@@ -1,140 +0,0 @@
From 4fe21f66991abeb1905e24c3bc3c634543d959a2 Mon Sep 17 00:00:00 2001
From: Delgan <delgan.py@gmail.com>
Date: Sun, 17 Jul 2022 09:18:56 +0200
Subject: [PATCH] Fix "repr()" tests failing on Python 3.11
---
tests/test_repr.py | 87 +++++++++++++++++++---------------------------
1 file changed, 36 insertions(+), 51 deletions(-)
diff --git a/tests/test_repr.py b/tests/test_repr.py
index ba48839..76f413d 100644
--- a/tests/test_repr.py
+++ b/tests/test_repr.py
@@ -1,34 +1,11 @@
-import builtins
import logging
import pathlib
import re
import sys
-from inspect import iscoroutinefunction
-import loguru
from loguru import logger
-class Wrapper:
- def __init__(self, wrapped, *, repr, name):
- self._wrapped = wrapped
- self._repr = repr
- self._name = name
- self.raised = False
-
- def __repr__(self):
- return self._repr
-
- def __getattr__(self, name):
- if name == "__name__":
- if self._name is None:
- self.raised = True
- raise AttributeError
- else:
- return self._name
- return getattr(self._wrapped, name)
-
-
def test_no_handler():
assert repr(logger) == "<loguru.logger handlers=[]>"
@@ -112,22 +89,30 @@ def my_function(message):
assert repr(logger) == "<loguru.logger handlers=[(id=0, level=10, sink=my_function)]>"
-def test_function_without_name(monkeypatch):
- function = Wrapper(lambda _: None, repr="<FunctionWithout>", name=None)
- monkeypatch.setattr(builtins, "callable", lambda x: x is function or callable(x))
+def test_callable_without_name():
+ class Function:
+ def __call__(self):
+ pass
+
+ def __repr__(self):
+ return "<FunctionWithout>"
- logger.add(function)
+ logger.add(Function())
assert repr(logger) == "<loguru.logger handlers=[(id=0, level=10, sink=<FunctionWithout>)]>"
- assert function.raised
-def test_function_with_empty_name(monkeypatch):
- function = Wrapper(lambda _: None, repr="<FunctionEmpty>", name="")
- monkeypatch.setattr(builtins, "callable", lambda x: x is function or callable(x))
+def test_callable_with_empty_name():
+ class Function:
+ __name__ = ""
+
+ def __call__(self):
+ pass
+
+ def __repr__(self):
+ return "<FunctionEmpty>"
- logger.add(function)
+ logger.add(Function())
assert repr(logger) == "<loguru.logger handlers=[(id=0, level=10, sink=<FunctionEmpty>)]>"
- assert not function.raised
def test_coroutine_function():
@@ -138,32 +123,32 @@ async def my_async_function(message):
assert repr(logger) == "<loguru.logger handlers=[(id=0, level=10, sink=my_async_function)]>"
-def test_coroutine_function_without_name(monkeypatch):
- async_function = Wrapper(lambda _: None, repr="<AsyncFunctionWithout>", name=None)
- monkeypatch.setattr(
- loguru._logger,
- "iscoroutinefunction",
- lambda x: x is async_function or iscoroutinefunction(x),
- )
+def test_coroutine_callable_without_name():
+ class CoroutineFunction:
+ async def __call__(self):
+ pass
+
+ def __repr__(self):
+ return "<AsyncFunctionWithout>"
- logger.add(async_function)
+ logger.add(CoroutineFunction())
assert (
repr(logger) == "<loguru.logger handlers=[(id=0, level=10, sink=<AsyncFunctionWithout>)]>"
)
- assert async_function.raised
-def test_coroutine_function_with_empty_name(monkeypatch):
- async_function = Wrapper(lambda _: None, repr="<AsyncFunctionEmpty>", name="")
- monkeypatch.setattr(
- loguru._logger,
- "iscoroutinefunction",
- lambda x: x is async_function or iscoroutinefunction(x),
- )
+def test_coroutine_function_with_empty_name():
+ class CoroutineFunction:
+ __name__ = ""
+
+ def __call__(self):
+ pass
+
+ def __repr__(self):
+ return "<AsyncFunctionEmpty>"
- logger.add(async_function)
+ logger.add(CoroutineFunction())
assert repr(logger) == "<loguru.logger handlers=[(id=0, level=10, sink=<AsyncFunctionEmpty>)]>"
- assert not async_function.raised
def test_standard_handler():

View File

@@ -29,6 +29,7 @@ Fri May 5 12:35:44 UTC 2023 - Dirk Müller <dmueller@suse.com>
time (#600). time (#600).
* Raise exception if `logger.catch()` is used to wrap a class * Raise exception if `logger.catch()` is used to wrap a class
instead of a function to avoid unexpected behavior (#623). instead of a function to avoid unexpected behavior (#623).
- drop python311.patch, loguru-fix-repr-tests.patch: upstream
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Apr 21 12:28:02 UTC 2023 - Dirk Müller <dmueller@suse.com> Fri Apr 21 12:28:02 UTC 2023 - Dirk Müller <dmueller@suse.com>

View File

@@ -1,62 +0,0 @@
From 5b77724ca75aa8f4b1c8866e0b786c3cbe30ca99 Mon Sep 17 00:00:00 2001
From: Delgan <delgan.py@gmail.com>
Date: Sat, 28 May 2022 16:09:23 +0200
Subject: [PATCH] Fix failing tests on Python 3.11 (#654)
---
.github/workflows/tests.yml | 1 +
CHANGELOG.rst | 1 +
README.rst | 6 +++---
tests/test_filesink_rotation.py | 4 ++--
tests/test_interception.py | 11 ++++++-----
5 files changed, 13 insertions(+), 10 deletions(-)
Index: loguru-0.6.0/tests/test_filesink_rotation.py
===================================================================
--- loguru-0.6.0.orig/tests/test_filesink_rotation.py
+++ loguru-0.6.0/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
Index: loguru-0.6.0/tests/test_interception.py
===================================================================
--- loguru-0.6.0.orig/tests/test_interception.py
+++ loguru-0.6.0/tests/test_interception.py
@@ -1,4 +1,5 @@
import logging
+import sys
from loguru import logger
@@ -14,7 +15,7 @@ class InterceptHandler(logging.Handler):
level = record.levelno
# Find caller from where originated the logged message
- frame, depth = logging.currentframe(), 2
+ frame, depth = sys._getframe(6), 6
while 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"