-
-
Notifications
You must be signed in to change notification settings - Fork 245
Sym two #814
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
Sym two #814
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f4c0ed6
some changes to file reading
etiennerichart 347707d
Some work on symbolic link files
etiennerichart 3f13a28
Cleaned up symlink fix ideas
etiennerichart 47ea5ee
More clean up
etiennerichart 6eff3b2
Make it easier to test different methods
etiennerichart 8e08f3a
Found an even better way. useNameSubname = 4
etiennerichart 2b96e8d
"Used os.path.realpath to fix issue"
etiennerichart 44f76f7
Removed code that I was using for testing
etiennerichart 513f37d
Made variable to store paths for comparison.
etiennerichart 01a6a4c
further finalize changes to importcompletion.py
etiennerichart 2edc977
Working on test but am having issues with the try
etiennerichart 62bed48
replaced import test file with them file directory
etiennerichart 45ada74
fixed importtest.py
etiennerichart 9fafb2e
moved and renamed importtest to test folder
etiennerichart 52cef9f
cleaned up test file
etiennerichart 6983428
improved test
etiennerichart 5928198
made it so test skips in python 2
etiennerichart dbc1d4f
made skipping work
etiennerichart 5f15d7d
removed chdir and made better test skip
etiennerichart 8bd85e9
fix symbolic links for the test
etiennerichart 0a29731
used black auto format
etiennerichart cec627a
improved test to work on other computers
etiennerichart 629bf1e
made testing strickter
etiennerichart 11369fc
further testing
etiennerichart 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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
from bpython.test import unittest | ||
from bpython.importcompletion import find_modules | ||
import os, sys, tempfile | ||
|
||
|
||
@unittest.skipIf(sys.version_info[0] <= 2, "Test doesn't work in python 2.") | ||
class TestAvoidSymbolicLinks(unittest.TestCase): | ||
def setUp(self): | ||
with tempfile.TemporaryDirectory() as import_test_folder: | ||
os.mkdir(os.path.join(import_test_folder, "Level0")) | ||
os.mkdir(os.path.join(import_test_folder, "Right")) | ||
os.mkdir(os.path.join(import_test_folder, "Left")) | ||
|
||
current_path = os.path.join(import_test_folder, "Level0") | ||
with open( | ||
os.path.join(current_path, "__init__.py"), "x" | ||
) as init_file: | ||
pass | ||
|
||
current_path = os.path.join(current_path, "Level1") | ||
os.mkdir(current_path) | ||
with open( | ||
os.path.join(current_path, "__init__.py"), "x" | ||
) as init_file: | ||
pass | ||
|
||
current_path = os.path.join(current_path, "Level2") | ||
os.mkdir(current_path) | ||
with open( | ||
os.path.join(current_path, "__init__.py"), "x" | ||
) as init_file: | ||
pass | ||
|
||
os.symlink( | ||
os.path.join(import_test_folder, "Level0/Level1"), | ||
os.path.join(current_path, "Level3"), | ||
True, | ||
) | ||
|
||
current_path = os.path.join(import_test_folder, "Right") | ||
with open( | ||
os.path.join(current_path, "__init__.py"), "x" | ||
) as init_file: | ||
pass | ||
|
||
os.symlink( | ||
os.path.join(import_test_folder, "Left"), | ||
os.path.join(current_path, "toLeft"), | ||
True, | ||
) | ||
|
||
current_path = os.path.join(import_test_folder, "Left") | ||
with open( | ||
os.path.join(current_path, "__init__.py"), "x" | ||
) as init_file: | ||
pass | ||
|
||
os.symlink( | ||
os.path.join(import_test_folder, "Right"), | ||
os.path.join(current_path, "toRight"), | ||
True, | ||
) | ||
|
||
self.foo = list(find_modules(os.path.abspath(import_test_folder))) | ||
self.filepaths = [ | ||
"Left.toRight.toLeft", | ||
"Left.toRight", | ||
"Left", | ||
"Level0.Level1.Level2.Level3", | ||
"Level0.Level1.Level2", | ||
"Level0.Level1", | ||
"Level0", | ||
"Right", | ||
"Right.toLeft", | ||
"Right.toLeft.toRight", | ||
] | ||
|
||
def test_simple_symbolic_link_loop(self): | ||
for thing in self.foo: | ||
self.assertTrue(thing in self.filepaths) | ||
if thing == "Left.toRight.toLeft": | ||
self.filepaths.remove("Right.toLeft") | ||
self.filepaths.remove("Right.toLeft.toRight") | ||
if thing == "Right.toLeft.toRight": | ||
self.filepaths.remove("Left.toRight.toLeft") | ||
self.filepaths.remove("Left.toRight") | ||
self.filepaths.remove(thing) | ||
self.assertFalse(self.filepaths) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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.
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.
the convention being followed here is two lines between top-level statements. You should
pip install black
and run black on this file; that will autoformat it, dealing with these details. Or better you can set up VSCode to run black automatically.