-
Notifications
You must be signed in to change notification settings - Fork 0
tf 2 #17
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
base: main
Are you sure you want to change the base?
tf 2 #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
|
|
||
| import pytest | ||
| import warnings | ||
| from mock import Mock, call, patch | ||
| from mock import Mock, patch | ||
| from thefuck.utils import default_settings, \ | ||
| memoize, get_closest, get_all_executables, replace_argument, \ | ||
| get_all_matched_commands, is_app, for_app, cache, \ | ||
|
|
@@ -76,24 +76,6 @@ def test_get_all_executables(): | |
| assert 'fuck' not in all_callables | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def os_environ_pathsep(monkeypatch, path, pathsep): | ||
| env = {'PATH': path} | ||
| monkeypatch.setattr('os.environ', env) | ||
| monkeypatch.setattr('os.pathsep', pathsep) | ||
| return env | ||
|
|
||
|
|
||
| @pytest.mark.usefixtures('no_memoize', 'os_environ_pathsep') | ||
| @pytest.mark.parametrize('path, pathsep', [ | ||
| ('/foo:/bar:/baz:/foo/bar', ':'), | ||
| (r'C:\\foo;C:\\bar;C:\\baz;C:\\foo\\bar', ';')]) | ||
| def test_get_all_executables_pathsep(path, pathsep): | ||
| with patch('thefuck.utils.Path') as Path_mock: | ||
| get_all_executables() | ||
| Path_mock.assert_has_calls([call(p) for p in path.split(pathsep)], True) | ||
|
|
||
|
Comment on lines
78
to
-95
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Info 🐛 BugTests invoking get_all_executables run against real OS PATH and os.pathsep after removal of os_environ_pathsep fixture, causing non-determinism. Issue Explanation
Reply if you have any questions or let me know if I missed something. Don't forget to react with a 👍 or 👎 to the comments made by Blar to help us improve. |
||
|
|
||
| @pytest.mark.parametrize('args, result', [ | ||
| (('apt-get instol vim', 'instol', 'install'), 'apt-get install vim'), | ||
| (('git brnch', 'brnch', 'branch'), 'git branch')]) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -118,7 +118,7 @@ def _safe(fn, fallback): | |||||
| tf_entry_points = ['thefuck', 'fuck'] | ||||||
|
|
||||||
| bins = [exe.name.decode('utf8') if six.PY2 else exe.name | ||||||
| for path in os.environ.get('PATH', '').split(os.pathsep) | ||||||
| for path in os.environ.get('PATH', '').split(':') | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainCritical: Hardcoded path separator breaks Windows compatibility. This change from Apply this diff to restore cross-platform compatibility: - for path in os.environ.get('PATH', '').split(':')
+ for path in os.environ.get('PATH', '').split(os.pathsep)Let me verify if there are other usages of PATH splitting in the codebase: 🏁 Script executed: #!/bin/bash
# Search for other PATH splitting patterns in the codebase
rg -n "PATH.*split" --type py
rg -n "os\.pathsep" --type pyLength of output: 1980 Critical: Hardcoded path separator breaks Windows compatibility The change at Locations needing a fix:
Apply this diff to restore cross-platform behavior: - for path in os.environ.get('PATH', '').split(':')
+ for path in os.environ.get('PATH', '').split(os.pathsep)📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsThere was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Error 🐛 BugIncorrect splitting of PATH environment variable on ':' breaks Windows path handling in executable search. Issue Explanation
Reply if you have any questions or let me know if I missed something. Don't forget to react with a 👍 or 👎 to the comments made by Blar to help us improve. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 Warning 🐛 BugHardcoded ':' used instead of os.pathsep for splitting PATH, breaking Windows support. Issue Explanation
Reply if you have any questions or let me know if I missed something. Don't forget to react with a 👍 or 👎 to the comments made by Blar to help us improve. |
||||||
| for exe in _safe(lambda: list(Path(path).iterdir()), []) | ||||||
| if not _safe(exe.is_dir, True) | ||||||
| and exe.name not in tf_entry_points] | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
❓ Verification inconclusive
Consider restoring path separator test coverage.
According to the AI summary, tests for path separator behavior were removed. Given the critical platform compatibility issue in
utils.py(hardcoded colon instead ofos.pathsep), having test coverage for cross-platform PATH handling would be valuable to catch such regressions.Let me check what path separator related tests were removed:
🏁 Script executed:
Length of output: 56
Restore cross-platform PATH handling tests
Tests covering
os.pathsepbehavior appear to have been removed, and there’s currently no coverage to catch regressions in how we split or join PATH entries on different platforms. Please add back tests that verify:os.pathsepos.pathsepSuggested location for new tests:
🤖 Prompt for AI Agents