Skip to content

Commit 6090183

Browse files
committed
Move integration tests to its folder
1 parent 3363240 commit 6090183

File tree

4 files changed

+202
-188
lines changed

4 files changed

+202
-188
lines changed

tests/integration/test_literal.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""Tests that need installation of other packages."""
2+
# TODO: find a way to install example-isort-formatting-plugin to pass tests
3+
# import isort.literal
4+
5+
# from isort.settings import Config
6+
7+
8+
# def test_value_assignment_list():
9+
# assert isort.literal.assignment("x = ['b', 'a']", "list", "py") == "x = ['a', 'b']"
10+
# assert (
11+
# isort.literal.assignment("x = ['b', 'a']", "list", "py", Config(formatter="example"))
12+
# == 'x = ["a", "b"]'
13+
# )
+188
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
"""Tests that need installation of other packages."""
2+
# TODO: find a way to install example-isort-formatting-plugin to pass tests
3+
# from io import StringIO
4+
5+
# import pytest
6+
7+
# import isort
8+
# from isort import api, exceptions
9+
10+
11+
# def test_isort_supports_formatting_plugins():
12+
# """Test to ensure isort provides a way to create and share formatting plugins.
13+
# See: https://github.com/pycqa/isort/issues/1353.
14+
# """
15+
# # formatting plugin
16+
# assert isort.code("import a", formatter="example") == "import a\n"
17+
# # non-existent plugin
18+
# with pytest.raises(exceptions.FormattingPluginDoesNotExist):
19+
# assert isort.code("import a", formatter="madeupfake") == "import a\n"
20+
21+
22+
# def test_isort_literals_issue_1358():
23+
# assert (
24+
# isort.code(
25+
# """
26+
# import x
27+
# import a
28+
29+
30+
# # isort: list
31+
# __all__ = ["b", "a", "b"]
32+
33+
# # isort: unique-list
34+
# __all__ = ["b", "a", "b"]
35+
36+
# # isort: tuple
37+
# __all__ = ("b", "a", "b")
38+
39+
# # isort: unique-tuple
40+
# __all__ = ("b", "a", "b")
41+
42+
# # isort: set
43+
# __all__ = {"b", "a", "b"}
44+
45+
46+
# def method():
47+
# # isort: list
48+
# x = ["b", "a"]
49+
50+
51+
# # isort: dict
52+
# y = {"z": "z", "b": "b", "b": "c"}"""
53+
# )
54+
# == """
55+
# import a
56+
# import x
57+
58+
# # isort: list
59+
# __all__ = ['a', 'b', 'b']
60+
61+
# # isort: unique-list
62+
# __all__ = ['a', 'b']
63+
64+
# # isort: tuple
65+
# __all__ = ('a', 'b', 'b')
66+
67+
# # isort: unique-tuple
68+
# __all__ = ('a', 'b')
69+
70+
# # isort: set
71+
# __all__ = {'a', 'b'}
72+
73+
74+
# def method():
75+
# # isort: list
76+
# x = ['a', 'b']
77+
78+
79+
# # isort: dict
80+
# y = {'b': 'c', 'z': 'z'}"""
81+
# )
82+
# assert (
83+
# isort.code(
84+
# """
85+
# import x
86+
# import a
87+
88+
89+
# # isort: list
90+
# __all__ = ["b", "a", "b"]
91+
92+
# # isort: unique-list
93+
# __all__ = ["b", "a", "b"]
94+
95+
# # isort: tuple
96+
# __all__ = ("b", "a", "b")
97+
98+
# # isort: unique-tuple
99+
# __all__ = ("b", "a", "b")
100+
101+
# # isort: set
102+
# __all__ = {"b", "a", "b"}
103+
104+
105+
# def method():
106+
# # isort: list
107+
# x = ["b", "a"]
108+
109+
110+
# # isort: assignments
111+
# d = 1
112+
# b = 2
113+
# a = 3
114+
115+
# # isort: dict
116+
# y = {"z": "z", "b": "b", "b": "c"}""",
117+
# formatter="example",
118+
# )
119+
# == """
120+
# import a
121+
# import x
122+
123+
# # isort: list
124+
# __all__ = ["a", "b", "b"]
125+
126+
# # isort: unique-list
127+
# __all__ = ["a", "b"]
128+
129+
# # isort: tuple
130+
# __all__ = ("a", "b", "b")
131+
132+
# # isort: unique-tuple
133+
# __all__ = ("a", "b")
134+
135+
# # isort: set
136+
# __all__ = {"a", "b"}
137+
138+
139+
# def method():
140+
# # isort: list
141+
# x = ["a", "b"]
142+
143+
144+
# # isort: assignments
145+
# a = 3
146+
# b = 2
147+
# d = 1
148+
149+
# # isort: dict
150+
# y = {"b": "c", "z": "z"}"""
151+
# )
152+
# assert api.sort_stream(
153+
# input_stream=StringIO(
154+
# """
155+
# import a
156+
# import x
157+
158+
# # isort: list
159+
# __all__ = ["b", "a", "b"]
160+
161+
# # isort: unique-list
162+
# __all__ = ["b", "a", "b"]
163+
164+
# # isort: tuple
165+
# __all__ = ("b", "a", "b")
166+
167+
# # isort: unique-tuple
168+
# __all__ = ("b", "a", "b")
169+
170+
# # isort: set
171+
# __all__ = {"b", "a", "b"}
172+
173+
174+
# def method():
175+
# # isort: list
176+
# x = ["b", "a"]
177+
178+
179+
# # isort: assignments
180+
# d = 1
181+
# b = 2
182+
# a = 3
183+
184+
# # isort: dict
185+
# y = {"z": "z", "b": "b", "b": "c"}""",
186+
# ),
187+
# output_stream=StringIO(),
188+
# )

tests/unit/test_literal.py

-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import isort.literal
44
from isort import exceptions
5-
from isort.settings import Config
65

76

87
def test_value_mismatch():
@@ -20,14 +19,6 @@ def test_invalid_sort_type():
2019
isort.literal.assignment("x = [1, 2, 3", "tuple-list-not-exist", "py")
2120

2221

23-
def test_value_assignment_list():
24-
assert isort.literal.assignment("x = ['b', 'a']", "list", "py") == "x = ['a', 'b']"
25-
assert (
26-
isort.literal.assignment("x = ['b', 'a']", "list", "py", Config(formatter="example"))
27-
== 'x = ["a", "b"]'
28-
)
29-
30-
3122
def test_value_assignment_assignments():
3223
assert isort.literal.assignment("b = 1\na = 2\n", "assignments", "py") == "a = 2\nb = 1\n"
3324

0 commit comments

Comments
 (0)