Skip to content

Commit f482e5f

Browse files
authored
Merge pull request #68 from Laksh0p/patch-3
Refactor test_worldclock to capture output correctly
2 parents e3f8b02 + 8fb5e71 commit f482e5f

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

tests/test_worldclock.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@
4545
),
4646
],
4747
)
48-
def test_worldclock(monkeypatch, capsys, args, expected):
48+
def test_worldclock(monkeypatch, args, expected):
4949
mock_env = {
5050
"TIMEZONE_LIST": '["Europe/Berlin", "Australia/Sydney", "America/Los_Angeles"]'
5151
}
5252
monkeypatch.setattr(os, "environ", mock_env)
53-
worldclock.convert_time(*args)
54-
captured = capsys.readouterr()
55-
assert captured.out == expected
53+
result = worldclock.convert_time(*args)
54+
output = "\n".join(f"{zone:25} {time}" for zone, time in result) + "\n"
55+
assert output == expected
5656

5757

5858
def test_bad_timezone_json(monkeypatch, capsys):
@@ -123,11 +123,11 @@ def test_bad_timezone_entered(monkeypatch, capsys):
123123
),
124124
],
125125
)
126-
def test_worldclock_with_date_offset(monkeypatch, capsys, args, expected):
126+
def test_worldclock_with_date_offset(monkeypatch, args, expected):
127127
mock_env = {
128128
"TIMEZONE_LIST": '["Europe/Berlin", "Australia/Sydney", "America/Los_Angeles"]'
129129
}
130130
monkeypatch.setattr(os, "environ", mock_env)
131-
worldclock.convert_time(*args)
132-
captured = capsys.readouterr()
133-
assert captured.out == expected
131+
result = worldclock.convert_time(*args)
132+
output = "\n".join(f"{zone:25} {time}" for zone, time in result) + "\n"
133+
assert output == expected

0 commit comments

Comments
 (0)