-
Notifications
You must be signed in to change notification settings - Fork 1.2k
dvc/dagascii: Use pager instead of AsciiCanvas._do_draw #2815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c17cf2b
dvc/dagascii: Use less instead of AsciiCanvas._do_draw
cade3b3
Add is_exec_found to utils and use it in dagascii module
3e163f1
Rename and move DVC_PAGER_ENV_NAME to env.py file
a6a3cbc
Reduce nested ifs in find_pager
f79711d
Fix code checks
ab3ccf0
Use os.devnull + do not check if system exists for os module
8977958
Make pager info box to be a simple warning
c864ca9
Move is_exec_found(..) to dvc/dagascii.py
128f60e
Add test_dagascii.py + make find_pager() use DVC_PAGER
8fb754a
Simplify if in find_pager
6cfc831
Use mocker fixture in test_dagascii.py
ed4e951
Use monkeypatch in test_dagascii.py
ffefab1
Remove make_pager.cmd attribute
44df59f
Fix test_dagascii tests
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 +1,2 @@ | ||
DVC_DAEMON = "DVC_DAEMON" | ||
DVC_PAGER = "DVC_PAGER" | ||
efiop marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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 hidden or 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,41 @@ | ||
from dvc import dagascii | ||
from dvc.env import DVC_PAGER | ||
|
||
|
||
def test_find_pager_uses_default_pager_when_found(mocker): | ||
mocker.patch("sys.stdout.isatty", return_value=True) | ||
mocker.patch("os.system", return_value=0) | ||
m_make_pager = mocker.patch.object(dagascii, "make_pager") | ||
|
||
dagascii.find_pager() | ||
|
||
m_make_pager.assert_called_once_with(dagascii.DEFAULT_PAGER_FORMATTED) | ||
|
||
|
||
def test_find_pager_returns_plain_pager_when_default_missing(mocker): | ||
mocker.patch("sys.stdout.isatty", return_value=True) | ||
mocker.patch("os.system", return_value=1) | ||
|
||
pager = dagascii.find_pager() | ||
|
||
assert pager.__name__ == "plainpager" | ||
|
||
|
||
def test_find_pager_uses_custom_pager_when_env_var_is_defined( | ||
mocker, monkeypatch | ||
): | ||
mocker.patch("sys.stdout.isatty", return_value=True) | ||
m_make_pager = mocker.patch.object(dagascii, "make_pager") | ||
monkeypatch.setenv(DVC_PAGER, dagascii.DEFAULT_PAGER) | ||
|
||
dagascii.find_pager() | ||
|
||
m_make_pager.assert_called_once_with(dagascii.DEFAULT_PAGER) | ||
|
||
|
||
def test_find_pager_returns_plain_pager_when_is_not_atty(mocker): | ||
mocker.patch("sys.stdout.isatty", return_value=False) | ||
|
||
pager = dagascii.find_pager() | ||
|
||
assert pager.__name__ == "plainpager" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.