Skip to content

Commit 8091169

Browse files
leej3github-actions[bot]
authored andcommitted
autopep8 fix
1 parent 37dfc9f commit 8091169

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

Diff for: tests/ignite/handlers/test_fbresearch_logger.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
import pytest
21
import logging
3-
from unittest.mock import MagicMock, _Call
2+
import re
3+
from unittest.mock import _Call, MagicMock
4+
5+
import pytest
6+
47
from ignite.engine import Engine, Events
58
from ignite.handlers.fbresearch_logger import FBResearchLogger # Adjust the import path as necessary
6-
import re
9+
710

811
@pytest.fixture
912
def mock_engine():
@@ -14,6 +17,7 @@ def mock_engine():
1417
engine.state.iteration = 50
1518
return engine
1619

20+
1721
@pytest.fixture
1822
def mock_logger():
1923
return MagicMock(spec=logging.Logger)
@@ -23,6 +27,7 @@ def mock_logger():
2327
def fb_research_logger(mock_logger):
2428
yield FBResearchLogger(logger=mock_logger, show_output=True)
2529

30+
2631
# Test logging with a dictionary output
2732
def test_logging_dict_output(mock_engine, fb_research_logger):
2833
mock_engine.state.output = {"loss": 0.456, "accuracy": 0.789}
@@ -31,6 +36,7 @@ def test_logging_dict_output(mock_engine, fb_research_logger):
3136
fb_research_logger.logger.info.assert_called_once()
3237
assert "accuracy: 0.7890" in fb_research_logger.logger.info.call_args_list[-1].args[0]
3338

39+
3440
# Test logging with a list output
3541
def test_logging_list_output(mock_engine, fb_research_logger):
3642
mock_engine.state.output = [0.456, 0.789]
@@ -39,6 +45,7 @@ def test_logging_list_output(mock_engine, fb_research_logger):
3945
fb_research_logger.logger.info.assert_called_once()
4046
assert "0.456" in fb_research_logger.logger.info.call_args_list[-1].args[0]
4147

48+
4249
# Test logging with a tuple output
4350
def test_logging_tuple_output(mock_engine, fb_research_logger):
4451
mock_engine.state.output = (0.456, 0.789)
@@ -49,20 +56,13 @@ def test_logging_tuple_output(mock_engine, fb_research_logger):
4956

5057

5158
@pytest.mark.parametrize(
52-
"output,expected_pattern",
53-
[
54-
(
55-
{"loss": 0.456, "accuracy": 0.789},
56-
r"loss. *0.456.*accuracy. *0.789"
57-
),
58-
(
59-
[0.456, 0.789],
60-
r"0.456.*0.789"
61-
62-
),
63-
]
59+
"output,expected_pattern",
60+
[
61+
({"loss": 0.456, "accuracy": 0.789}, r"loss. *0.456.*accuracy. *0.789"),
62+
([0.456, 0.789], r"0.456.*0.789"),
63+
],
6464
)
65-
def test_output_formatting(mock_engine, fb_research_logger,output,expected_pattern):
65+
def test_output_formatting(mock_engine, fb_research_logger, output, expected_pattern):
6666
# Ensure the logger correctly formats and logs the output for each type
6767
mock_engine.state.output = output
6868
fb_research_logger.attach(mock_engine, name="Test", every=1)

0 commit comments

Comments
 (0)