Skip to content

Commit 2edc977

Browse files
Working on test but am having issues with the try
1 parent 01a6a4c commit 2edc977

1 file changed

Lines changed: 41 additions & 4 deletions

File tree

importtest.py

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,44 @@
11
from bpython.importcompletion import find_modules
2-
import os
2+
import os, sys, tempfile
33

4-
foo = find_modules(os.path.abspath("./importtestfolder"))
4+
with tempfile.TemporaryDirectory() as import_test_folder:
5+
try:
6+
os.chdir(import_test_folder)
7+
except:
8+
print("Can't change the Current Working Directory")
9+
sys.exit()
510

6-
for thing in foo:
7-
print("YIELD:", thing)
11+
os.mkdir(os.path.join(os.getcwd(), "Level0")
12+
try:
13+
os.chdir(Level0)
14+
open("__init__.py", w)
15+
except OSError:
16+
print("Can't change the Current Working Directory")
17+
sys.exit()
18+
19+
os.mkdir(os.path.join(os.getcwd(), "Level1")
20+
try:
21+
os.chdir(Level1)
22+
open("__init__.py", w)
23+
except OSError:
24+
print("Can't change the Current Working Directory")
25+
sys.exit()
26+
27+
os.mkdir(os.path.join(os.getcwd(), "Level2")
28+
try:
29+
os.chdir(Level2)
30+
open("__init__.py", w)
31+
except OSError:
32+
print("Can't change the Current Working Directory")
33+
sys.exit()
34+
35+
os.symlink(
36+
"import_test_folder/Level0/Level1",
37+
os.path.join(os.getcwd, "Level3"),
38+
True,
39+
)
40+
41+
foo = find_modules(os.path.abspath("import_test_folder"))
42+
43+
for thing in foo:
44+
print("YIELD:", thing)

0 commit comments

Comments
 (0)