GitHub
· Extracted in 1945 ms
Sym two by etiennerichart · Pull Request #814 · bpython/bpython
Source: https://github.com/bpython/bpython/pull/814
Repository navigation
Sym two - #814
Merged
thomasballinger merged 24 commits into
bpython:master from
etiennerichart:sym-two
Jul 22, 2020
Merged
Conversation
Copy link
Copy Markdown
Contributor
Use os.path.realpath to see the source of symbolic links and makes sure that we are not in a loop. Also include importtest.py and importtestfolder to test if program gets stuck in a loop.
Resolves #806
etiennerichart
added 9 commits
June 25, 2020 19:34
some changes to file reading
f4c0ed6
Some work on symbolic link files
347707d
Cleaned up symlink fix ideas
3f13a28
More clean up
47ea5ee
Make it easier to test different methods
6eff3b2
Found an even better way. useNameSubname = 4
8e08f3a
"Used os.path.realpath to fix issue"
2b96e8d
Removed code that I was using for testing
44f76f7
Made variable to store paths for comparison.
513f37d
thomasballinger
requested changes
Jul 1, 2020
View reviewed changes
Copy link
Copy Markdown
Member
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Thanks for exploring a few options here, I think I like this last one best.
Comment thread
bpython/importcompletion.py
Outdated
|
|
for subname in find_modules(pathname):
|
|
|
if subname != "__init__":
|
|
|
yield "%s.%s" % (name, subname)
|
|
|
pathReal = os.path.realpath(pathname)
|
Comment thread
bpython/importcompletion.py
Outdated
|
|
if subname != "__init__":
|
|
|
yield "%s.%s" % (name, subname)
|
|
|
pathReal = os.path.realpath(pathname)
|
|
|
if not pathReal in paths:
|
Comment thread
bpython/importcompletion.py
Outdated
|
|
|
|
|
def find_modules(path):
|
|
|
"""Find all modules (and packages) for a given directory."""
|
|
|
|
Comment thread
bpython/importcompletion.py
|
|
yield "%s.%s" % (name, subname)
|
|
|
yield name
|
|
|
|
|
|
|
sebastinas
requested changes
Jul 1, 2020
View reviewed changes
etiennerichart
added 2 commits
July 2, 2020 21:43
further finalize changes to importcompletion.py
01a6a4c
Working on test but am having issues with the try
2edc977
Copy link
Copy Markdown
Contributor
Author
|
@thomasballinger I am trying to write the test file but am having an issue with the try: on line 12. Also, I was wondering if the files made in the temp directory will be erased after the temp directory is closed or if they will keep taking up space.
|
thomasballinger
reviewed
Jul 7, 2020
View reviewed changes
Copy link
Copy Markdown
Member
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
See the docs for tempfile.TemporaryDirectory - the files in the temp directory will be erased along with the directory after exiting the context manager.
replaced import test file with them file directory
62bed48
Copy link
Copy Markdown
Contributor
Author
|
I have almost finished turning the test class into a test file but for some reason the test is passing when it should not. In the temp directory setup I have it print out what should appear and in what order and the 'Left' file is first. In the actual test 'Left' is last and yet the test still passes.
|
sebastinas
reviewed
Jul 8, 2020
View reviewed changes
fixed importtest.py
45ada74
Copy link
Copy Markdown
Contributor
Author
|
I have made the changes so that importtest now works. While I was debugging I used the nosetests -s command and it seems that the temp directory is showing up in (I bolded what I think is the temp dir), '..SS.S...........S..S.......................S...SSSSS...................................................... tmpfaxxkuhx
.tmptz3ajosr
.....S..............S.....SSS..........................S.....SS.SSSSSS.....................................................................SS....................SSSS...SS..............................S.S..........' Is there anything else I should do to integrate the test with the rest of the test files? Also, should I get rid of the print statements in the except, and is there something better than sys.exit to use since I am worried that it may interrupt the temp dir's auto cleanup. Would a break (out of the with) work?
|
Copy link
Copy Markdown
Contributor
|
Please move the test file to bpython/test.
|
moved and renamed importtest to test folder
9fafb2e
etiennerichart
marked this pull request as ready for review
July 8, 2020 20:08
sebastinas
requested changes
Jul 8, 2020
View reviewed changes
Copy link
Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Sorry, I've some more comments that I missed earlier.
etiennerichart
added 4 commits
July 9, 2020 09:23
cleaned up test file
52cef9f
improved test
6983428
made it so test skips in python 2
5928198
made skipping work
View comments on this commit
dbc1d4f
sebastinas
added this to the
release-0.20 milestone
Jul 11, 2020
thomasballinger
reviewed
Jul 12, 2020
View reviewed changes
Comment thread
bpython/test/test_import_not_cyclical.py
Outdated
|
|
|
|
|
else:
|
|
|
@unittest.skip()
|
|
|
@unittest.skip( "test doesn't work in python 2" )
|
removed chdir and made better test skip
5f15d7d
Copy link
Copy Markdown
Member
|
Now when I run this test after commenting out your fix, it still passes; so I'm worried this isn't testing what we think it is.
One problem I see is that sometimes you're using the string 'import_test_folder' when there's no folder that exists with that name. When I run your setup function (and then pause in it so I have time to examine the files) I see that the temporary directory is named /var/folders/ty/d8c6t0c176db_ll_xh2jqn_80000gn/T/tmp5kxo1jhg (this will be different every time) and it looks like this:
tomb ~$ tree /var/folders/ty/d8c6t0c176db_ll_xh2jqn_80000gn/T/tmp5kxo1jhg
/var/folders/ty/d8c6t0c176db_ll_xh2jqn_80000gn/T/tmp5kxo1jhg
├── Left
│ ├── __init__.py
│ └── toRight -> import_test_folder/Right
├── Level0
│ ├── Level1
│ │ ├── Level2
│ │ │ ├── Level3 -> import_test_folder/Level0/Level1
│ │ │ └── __init__.py
│ │ └── __init__.py
│ └── __init__.py
└── Right
├── __init__.py
└── toLeft -> import_test_folder/Left
5 directories, 8 files
```
One this to fix would be these symlink target filenames, and then check that the test fails without your fix, but passes with it.
|
etiennerichart
added 2 commits
July 16, 2020 09:34
fix symbolic links for the test
8bd85e9
used black auto format
0a29731
Copy link
Copy Markdown
Member
|
This fails for me locally now, but it looks close. If I sort both lists and print them, I get
actual: ['Left', 'Level0', 'Level0.Level1', 'Level0.Level1.Level2', 'Level0.Level1.Level2.Level3', 'Right', 'Right.toLeft', 'Right.toLeft.toRight']
expected: ['Left', 'Left.toRight', 'Left.toRight.toLeft', 'Level0', 'Level0.Level1', 'Level0.Level1.Level2', 'Level0.Level1.Level2.Level3', 'Right']
Is this passing for you?
It occurs to me that this could be nondeterministic since a given module can be referred to mulitple ways based on which filepath got our import discoverer there first, say if os.listdir() returned files in a different order we could end up with different names for the same modules. If this isn't passing for you yet either then we may not need to do this, but if it is and this is something nondeterministic we want to control we could sort the results of os.listdir() in the import completion code to ensure the same results each time.
|
Copy link
Copy Markdown
Contributor
Author
|
I think that the problem is that when going between left and right it went right first whereas on my computer it went left first
your computer : ['Right.toLeft', 'Right.toLeft.toRight']
mine: [ 'Left.toRight', 'Left.toRight.toLeft']
|
improved test to work on other computers
cec627a
Copy link
Copy Markdown
Member
|
Got it, I think we want to change the implementation then to sort. I think wrapping the os.listdir() call with sorted() like sorted(os.listdir()) would do it.
|
etiennerichart
added 2 commits
July 16, 2020 10:58
made testing strickter
629bf1e
further testing
11369fc
thomasballinger
requested a review
from sebastinas
July 21, 2020 15:16
Copy link
Copy Markdown
Member
|
This alternative approach works for me, import completion will traverse the filesystem in the nondeterministic order determined by os.listdir() but both orders work in the test. @sebastinas thoughts?
|
sebastinas
approved these changes
Jul 22, 2020
View reviewed changes
Copy link
Copy Markdown
Contributor
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more .
Looks good to me, but please squash the commits when merging the changes.
thomasballinger
merged commit b2111bd
into
bpython : master
Jul 22, 2020
Sign up for free
to join this conversation on GitHub .
Already have an account?
Sign in to comment
Labels
None yet
3 participants
|
|