[issue41898] Any logging causes assertLogs to pass

2020-10-05 Thread Irit Katriel


Irit Katriel  added the comment:

Strike that - Troy has created the new issue 41943 so this one can remain 
closed.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-05 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests: +21560
pull_request: https://github.com/python/cpython/pull/22565

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-05 Thread Irit Katriel


Irit Katriel  added the comment:

Please reopen this issue. I understand after a discussion on stackoverflow what 
the problem is, and there is indeed a bug. I will create a PR with a unit test 
for it an a fix.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-04 Thread Irit Katriel


Irit Katriel  added the comment:

Troy, 

I'm also confused about how you would have liked assertLogs to behave you say:

1. I don't want to specify the logger because I don't care which logger the 
message comes from.

2. I don't want it to catch messages from other loggers (whatever other means 
here).  But -- see 1 -- you didn't specify the logger because you don't care 
which logger.

What do you expect assertLogs to do when you don't specify a logger?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-04 Thread Irit Katriel


Irit Katriel  added the comment:

I'm not sure my patch completely resolved this issue. I'm adding Antoine re the 
OP's question about the assertLogs API. 

> Doing so would make the test over-specific and fragile.  The requirement is > 
> that a warning be logged, not that a specific logger issue the warning.

My view is that your test is fragile because it just asks "was anything logged" 
without checking the log message. The docs show how to verify that the log 
message is what you expect it to be.

--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-04 Thread Vinay Sajip


Change by Vinay Sajip :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.10, Python 3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-04 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset faa8c6a8f1fe9c3bac31061e8a59a686b983ebb8 by Miss Skeleton (bot) 
in branch '3.9':
bpo-41898: add caveat on root logger seeing all messages in assertLogs doc 
(GH-22526) (GH-22540)
https://github.com/python/cpython/commit/faa8c6a8f1fe9c3bac31061e8a59a686b983ebb8


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-04 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21543
pull_request: https://github.com/python/cpython/pull/22540

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-04 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset b2611fac05ed391d68f09781903aae7394fab832 by Miss Skeleton (bot) 
in branch '3.8':
bpo-41898: add caveat on root logger seeing all messages in assertLogs doc 
(GH-22526) (GH-22537)
https://github.com/python/cpython/commit/b2611fac05ed391d68f09781903aae7394fab832


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-04 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset 1ed54435268b285964141fb74d47ceaa33ea79ab by Irit Katriel in 
branch 'master':
bpo-41898: add caveat on root logger seeing all messages in assertLogs doc 
(GH-22526)
https://github.com/python/cpython/commit/1ed54435268b285964141fb74d47ceaa33ea79ab


--
nosy: +vinay.sajip

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-04 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +21540
pull_request: https://github.com/python/cpython/pull/22537

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-04 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21541
pull_request: https://github.com/python/cpython/pull/22538

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-03 Thread Irit Katriel


Change by Irit Katriel :


--
keywords: +patch
pull_requests: +21531
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22526

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-10-03 Thread Irit Katriel


Irit Katriel  added the comment:

You didn't specify the logger in the assertLogs() call. 

The documentation says that "The default is the root logger, which will catch 
all messages."

https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertLogs

This is behaving as expected.

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41898] Any logging causes assertLogs to pass

2020-09-30 Thread Troy Daniels


New submission from Troy Daniels :

The following test code unexpectedly passes.

import logging
import unittest

LOG_FORMAT = '%(levelname)-10s %(asctime)s: %(message)s'


def set_up_logger(app_name, level=logging.INFO, file="test.log"):
formatter = logging.Formatter(LOG_FORMAT)
log = logging.getLogger(app_name)
# The next line lets the test pass
log.setLevel(level)
return log

logger = set_up_logger(__name__)

class TestLogging(unittest.TestCase):
def test_logging(self):
with self.assertLogs(level=logging.WARNING):
logger.info('foo')

Based on discussion at 
https://stackoverflow.com/questions/64141681/any-level-of-logging-lets-assertlogs-pass,
 it appears that I need to pass in the logger which is going to be doing the 
logging.  

Doing so would make the test over-specific and fragile.  The requirement is 
that a warning be logged, not that a specific logger issue the warning.

This was verified with Python 3.8.5 on a Mac, but probably exists in most/all 
other versions.

--
components: Tests
messages: 377719
nosy: udalrich.schermer
priority: normal
severity: normal
status: open
title: Any logging causes assertLogs to pass
type: behavior
versions: Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com