Skip to content

Commit 5928198

Browse files
made it so test skips in python 2
1 parent 6983428 commit 5928198

File tree

1 file changed

+72
-67
lines changed

1 file changed

+72
-67
lines changed

bpython/test/test_import_not_cyclical.py

Lines changed: 72 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,73 +2,78 @@
22
from bpython.importcompletion import find_modules
33
import os, sys, tempfile
44

5-
6-
class TestAvoidSymbolicLinks(unittest.TestCase):
7-
def setUp(self):
8-
with tempfile.TemporaryDirectory() as import_test_folder:
9-
os.chdir(import_test_folder)
10-
11-
os.mkdir(os.path.join(os.getcwd(), "Level0"))
12-
os.mkdir(os.path.join(os.getcwd(), "Right"))
13-
os.mkdir(os.path.join(os.getcwd(), "Left"))
14-
15-
os.chdir("Level0")
16-
with open("__init__.py", "w") as init_file:
17-
pass
18-
19-
os.mkdir(os.path.join(os.getcwd(), "Level1"))
20-
os.chdir("Level1")
21-
with open("__init__.py", "w") as init_file:
22-
pass
23-
24-
os.mkdir(os.path.join(os.getcwd(), "Level2"))
25-
os.chdir("Level2")
26-
with open("__init__.py", "w") as init_file:
27-
pass
28-
29-
os.symlink(
30-
"import_test_folder/Level0/Level1",
31-
os.path.join(os.getcwd(), "Level3"),
32-
True,
33-
)
34-
35-
os.chdir(import_test_folder)
36-
37-
os.chdir("Right")
38-
with open("__init__.py", "w") as init_file:
39-
pass
40-
41-
os.symlink(
42-
"import_test_folder/Left",
43-
os.path.join(os.getcwd(), "toLeft"),
44-
True,
45-
)
46-
47-
os.chdir(import_test_folder)
48-
49-
os.chdir("Left")
50-
with open("__init__.py", "w") as init_file:
51-
pass
52-
53-
os.symlink(
54-
"import_test_folder/Right",
55-
os.path.join(os.getcwd(), "toRight"),
56-
True,
57-
)
58-
59-
self.foo = list(find_modules(os.path.abspath(import_test_folder)))
60-
self.filepaths = [
61-
"Left",
62-
"Level0.Level1.Level2",
63-
"Level0.Level1",
64-
"Level0",
65-
"Right"
66-
]
67-
68-
def test_simple_symbolic_link_loop(self):
69-
for thing in self.foo:
70-
self.assertTrue(thing in self.filepaths)
71-
self.filepaths.remove(thing)
5+
if sys.version_info[0] > 2:
6+
class TestAvoidSymbolicLinks(unittest.TestCase):
7+
def setUp(self):
8+
with tempfile.TemporaryDirectory() as import_test_folder:
9+
os.chdir(import_test_folder)
10+
11+
os.mkdir(os.path.join(os.getcwd(), "Level0"))
12+
os.mkdir(os.path.join(os.getcwd(), "Right"))
13+
os.mkdir(os.path.join(os.getcwd(), "Left"))
14+
15+
os.chdir("Level0")
16+
with open("__init__.py", "w") as init_file:
17+
pass
18+
19+
os.mkdir(os.path.join(os.getcwd(), "Level1"))
20+
os.chdir("Level1")
21+
with open("__init__.py", "w") as init_file:
22+
pass
23+
24+
os.mkdir(os.path.join(os.getcwd(), "Level2"))
25+
os.chdir("Level2")
26+
with open("__init__.py", "w") as init_file:
27+
pass
28+
29+
os.symlink(
30+
"import_test_folder/Level0/Level1",
31+
os.path.join(os.getcwd(), "Level3"),
32+
True,
33+
)
34+
35+
os.chdir(import_test_folder)
36+
37+
os.chdir("Right")
38+
with open("__init__.py", "w") as init_file:
39+
pass
40+
41+
os.symlink(
42+
"import_test_folder/Left",
43+
os.path.join(os.getcwd(), "toLeft"),
44+
True,
45+
)
46+
47+
os.chdir(import_test_folder)
48+
49+
os.chdir("Left")
50+
with open("__init__.py", "w") as init_file:
51+
pass
52+
53+
os.symlink(
54+
"import_test_folder/Right",
55+
os.path.join(os.getcwd(), "toRight"),
56+
True,
57+
)
58+
59+
self.foo = list(find_modules(os.path.abspath(import_test_folder)))
60+
self.filepaths = [
61+
"Left",
62+
"Level0.Level1.Level2",
63+
"Level0.Level1",
64+
"Level0",
65+
"Right"
66+
]
67+
68+
def test_simple_symbolic_link_loop(self):
69+
for thing in self.foo:
70+
self.assertTrue(thing in self.filepaths)
71+
self.filepaths.remove(thing)
72+
73+
else:
74+
@unittest.skip()
75+
def test_skip():
76+
pass
7277

7378

7479
if __name__ == "__main__":

0 commit comments

Comments
 (0)