-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved logging-related code to
cleo.logging
package, tests to test_l…
…ogging.py, and renamed Handler subclass to CleoHandler
- Loading branch information
1 parent
280f693
commit 0846085
Showing
5 changed files
with
97 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import pytest | ||
|
||
from cleo.application import Application | ||
from cleo.testers.application_tester import ApplicationTester | ||
from tests.fixtures.foo4_command import Foo4Command | ||
|
||
|
||
if TYPE_CHECKING: | ||
from cleo.commands.command import Command | ||
|
||
|
||
@pytest.mark.parametrize("cmd", (Foo4Command(),)) | ||
def test_run_with_logging_integration_normal(cmd: Command) -> None: | ||
app = Application() | ||
app.add(cmd) | ||
|
||
tester = ApplicationTester(app) | ||
status_code = tester.execute(f"{cmd.name}") | ||
|
||
expected = "This is an warning log record\n" "This is an error log record\n" | ||
|
||
assert status_code == 0 | ||
assert tester.io.fetch_output() == expected | ||
|
||
|
||
@pytest.mark.parametrize("cmd", (Foo4Command(),)) | ||
def test_run_with_logging_integration_quiet(cmd: Command) -> None: | ||
app = Application() | ||
app.add(cmd) | ||
|
||
tester = ApplicationTester(app) | ||
status_code = tester.execute(f"{cmd.name} -q") | ||
|
||
assert status_code == 0 | ||
assert tester.io.fetch_output() == "" | ||
|
||
|
||
@pytest.mark.parametrize("cmd", (Foo4Command(),)) | ||
def test_run_with_logging_integration_verbose(cmd: Command) -> None: | ||
app = Application() | ||
app.add(cmd) | ||
|
||
tester = ApplicationTester(app) | ||
status_code = tester.execute(f"{cmd.name} -v") | ||
|
||
expected = ( | ||
"This is an info log record\n" | ||
"This is an warning log record\n" | ||
"This is an error log record\n" | ||
) | ||
|
||
assert status_code == 0 | ||
assert tester.io.fetch_output() == expected | ||
|
||
|
||
@pytest.mark.parametrize("cmd", (Foo4Command(),)) | ||
def test_run_with_logging_integration_very_verbose(cmd: Command) -> None: | ||
app = Application() | ||
app.add(cmd) | ||
|
||
tester = ApplicationTester(app) | ||
status_code = tester.execute(f"{cmd.name} -vv") | ||
|
||
expected = ( | ||
"This is an debug log record\n" | ||
"This is an info log record\n" | ||
"This is an warning log record\n" | ||
"This is an error log record\n" | ||
) | ||
|
||
assert status_code == 0 | ||
assert tester.io.fetch_output() == expected |