-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a summary line to the logging (#120)
- Loading branch information
Florian Maas
authored
Sep 19, 2022
1 parent
2b356ce
commit eb71583
Showing
5 changed files
with
86 additions
and
29 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
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,28 @@ | ||
import logging | ||
|
||
import pytest | ||
|
||
from deptry.core import Core | ||
|
||
|
||
def test_simple(): | ||
issues = { | ||
"missing": ["foo"], | ||
"obsolete": ["foo"], | ||
"transitive": ["foo"], | ||
"misplaced_dev": ["foo"], | ||
} | ||
with pytest.raises(SystemExit) as e: | ||
Core._exit(issues) | ||
|
||
assert e.type == SystemExit | ||
assert e.value.code == 1 | ||
|
||
|
||
def test_no_issues(): | ||
issues = {} | ||
with pytest.raises(SystemExit) as e: | ||
Core._exit(issues) | ||
|
||
assert e.type == SystemExit | ||
assert e.value.code == 0 |
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 |
---|---|---|
@@ -1,26 +1,46 @@ | ||
import logging | ||
|
||
import pytest | ||
|
||
from deptry.result_logger import ResultLogger | ||
|
||
|
||
def test_simple(): | ||
issues = { | ||
"missing": ["foo"], | ||
"obsolete": ["foo"], | ||
"transitive": ["foo"], | ||
"misplaced_dev": ["foo"], | ||
} | ||
with pytest.raises(SystemExit) as e: | ||
def test_logging_number_multiple(caplog): | ||
with caplog.at_level(logging.INFO): | ||
issues = { | ||
"missing": ["foo"], | ||
"obsolete": ["foo"], | ||
"transitive": ["foo"], | ||
"misplaced_dev": ["foo"], | ||
} | ||
ResultLogger(issues).log_and_exit() | ||
|
||
assert e.type == SystemExit | ||
assert e.value.code == 1 | ||
assert "There were 4 dependency issues found" in caplog.text | ||
assert "The project contains obsolete dependencies" in caplog.text | ||
assert "There are dependencies missing from the project's list of dependencies" in caplog.text | ||
assert "There are transitive dependencies that should be explicitly defined as dependencies" in caplog.text | ||
assert "There are imported modules from development dependencies detected" in caplog.text | ||
assert "For more information, see the documentation" in caplog.text | ||
|
||
|
||
def test_no_issues(): | ||
issues = {} | ||
with pytest.raises(SystemExit) as e: | ||
def test_logging_number_single(caplog): | ||
with caplog.at_level(logging.INFO): | ||
issues = { | ||
"missing": ["foo"], | ||
} | ||
ResultLogger(issues).log_and_exit() | ||
assert "There was 1 dependency issue found" in caplog.text | ||
|
||
assert e.type == SystemExit | ||
assert e.value.code == 0 | ||
|
||
def test_logging_number_none(caplog): | ||
with caplog.at_level(logging.INFO): | ||
issues = { | ||
"missing": [], | ||
} | ||
ResultLogger(issues).log_and_exit() | ||
assert "No dependency issues found" in caplog.text | ||
assert "There were 4 dependency issues found" not in caplog.text | ||
assert "The project contains obsolete dependencies" not in caplog.text | ||
assert "There are dependencies missing from the project's list of dependencies" not in caplog.text | ||
assert "There are transitive dependencies that should be explicitly defined as dependencies" not in caplog.text | ||
assert "There are imported modules from development dependencies detected" not in caplog.text | ||
assert "For more information, see the documentation" not in caplog.text |