[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [sbws/maint-1.1] fix: tests: debug log for tests by default



commit cde895003c0f3aab57008d6cb0a3f570b0a14011
Author: juga0 <juga@xxxxxxxxxx>
Date:   Fri Mar 5 16:29:14 2021 +0000

    fix: tests: debug log for tests by default
    
    and fix test that didn't consider that there might be other logs from
    other threads.
    
    Closes #33797.
---
 setup.cfg                         | 3 +++
 tests/unit/lib/test_resultdump.py | 9 +++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/setup.cfg b/setup.cfg
index 8d388e7..fd6b30c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -16,3 +16,6 @@ tag_prefix = v
 # String at the start of all unpacked tarball filenames.
 parentdir_prefix = sbws-
 
+[tool:pytest]
+log_cli=true
+log_cli_level=DEBUG
diff --git a/tests/unit/lib/test_resultdump.py b/tests/unit/lib/test_resultdump.py
index 1180bdb..5c1bd0d 100644
--- a/tests/unit/lib/test_resultdump.py
+++ b/tests/unit/lib/test_resultdump.py
@@ -2,6 +2,7 @@
 """Unit tests for resultdump."""
 
 import datetime
+import logging
 
 from sbws.lib.relaylist import Relay
 from sbws.lib.resultdump import (
@@ -37,10 +38,10 @@ def test_trim_results_ip_changed_on_changed_ipv6(caplog,
     results_dict = trim_results_ip_changed(resultdict_ip_not_changed,
                                            on_changed_ipv6=True)
     assert resultdict_ip_not_changed == results_dict
-    for record in caplog.records:
-        assert record.levelname == 'WARNING'
-    assert 'Reseting bandwidth results when IPv6 changes, ' \
-           'is not yet implemented.\n' in caplog.text
+    # There might be other logs from other threads.
+    with caplog.at_level(logging.WARNING):
+        assert 'Reseting bandwidth results when IPv6 changes, ' \
+            'is not yet implemented.\n' in caplog.text
 
 
 def test_resultdump(



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits