@alloy-js/python 0.5.0-dev.1 → 0.5.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/src/components/SourceFile.js +44 -32
- package/dist/dev/src/components/SourceFile.js.map +1 -1
- package/dist/dev/test/callsignatures.test.js +471 -297
- package/dist/dev/test/callsignatures.test.js.map +1 -1
- package/dist/dev/test/class-method-declaration.test.js +21 -10
- package/dist/dev/test/class-method-declaration.test.js.map +1 -1
- package/dist/dev/test/classdeclarations.test.js +459 -393
- package/dist/dev/test/classdeclarations.test.js.map +1 -1
- package/dist/dev/test/classinstantiations.test.js +201 -168
- package/dist/dev/test/classinstantiations.test.js.map +1 -1
- package/dist/dev/test/constructordeclaration.test.js +22 -11
- package/dist/dev/test/constructordeclaration.test.js.map +1 -1
- package/dist/dev/test/dataclassdeclarations.test.js +322 -368
- package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/dev/test/decoratorlist.test.js +96 -49
- package/dist/dev/test/decoratorlist.test.js.map +1 -1
- package/dist/dev/test/dundermethoddeclaration.test.js +22 -11
- package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/dev/test/enums.test.js +218 -184
- package/dist/dev/test/enums.test.js.map +1 -1
- package/dist/dev/test/externals.test.js +57 -45
- package/dist/dev/test/externals.test.js.map +1 -1
- package/dist/dev/test/factories.test.js +124 -50
- package/dist/dev/test/factories.test.js.map +1 -1
- package/dist/dev/test/functioncallexpressions.test.js +199 -164
- package/dist/dev/test/functioncallexpressions.test.js.map +1 -1
- package/dist/dev/test/functiondeclaration.test.js +439 -272
- package/dist/dev/test/functiondeclaration.test.js.map +1 -1
- package/dist/dev/test/imports.test.js +273 -221
- package/dist/dev/test/imports.test.js.map +1 -1
- package/dist/dev/test/memberexpressions.test.js +1237 -972
- package/dist/dev/test/memberexpressions.test.js.map +1 -1
- package/dist/dev/test/methoddeclaration.test.js +142 -78
- package/dist/dev/test/methoddeclaration.test.js.map +1 -1
- package/dist/dev/test/namepolicies.test.js +130 -94
- package/dist/dev/test/namepolicies.test.js.map +1 -1
- package/dist/dev/test/propertydeclaration.test.js +88 -59
- package/dist/dev/test/propertydeclaration.test.js.map +1 -1
- package/dist/dev/test/pydanticclassdeclarations.test.js +299 -347
- package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -1
- package/dist/dev/test/pydocs.test.js +888 -715
- package/dist/dev/test/pydocs.test.js.map +1 -1
- package/dist/dev/test/references.test.js +42 -35
- package/dist/dev/test/references.test.js.map +1 -1
- package/dist/dev/test/sourcefiles.test.js +1109 -841
- package/dist/dev/test/sourcefiles.test.js.map +1 -1
- package/dist/dev/test/staticmethoddeclaration.test.js +21 -10
- package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -1
- package/dist/dev/test/type-checking-imports.test.js +408 -359
- package/dist/dev/test/type-checking-imports.test.js.map +1 -1
- package/dist/dev/test/typereference.test.js +55 -40
- package/dist/dev/test/typereference.test.js.map +1 -1
- package/dist/dev/test/uniontypeexpression.test.js +222 -146
- package/dist/dev/test/uniontypeexpression.test.js.map +1 -1
- package/dist/dev/test/utils.js +39 -77
- package/dist/dev/test/utils.js.map +1 -1
- package/dist/dev/test/values.test.js +237 -101
- package/dist/dev/test/values.test.js.map +1 -1
- package/dist/dev/test/variables.test.js +321 -203
- package/dist/dev/test/variables.test.js.map +1 -1
- package/dist/dev/test/vitest.setup.js +2 -0
- package/dist/dev/test/vitest.setup.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts +2 -2
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +12 -0
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/test/callsignatures.test.js +346 -272
- package/dist/test/callsignatures.test.js.map +1 -1
- package/dist/test/class-method-declaration.test.js +7 -4
- package/dist/test/class-method-declaration.test.js.map +1 -1
- package/dist/test/classdeclarations.test.js +302 -288
- package/dist/test/classdeclarations.test.js.map +1 -1
- package/dist/test/classinstantiations.test.js +112 -103
- package/dist/test/classinstantiations.test.js.map +1 -1
- package/dist/test/constructordeclaration.test.js +7 -4
- package/dist/test/constructordeclaration.test.js.map +1 -1
- package/dist/test/dataclassdeclarations.test.js +134 -184
- package/dist/test/dataclassdeclarations.test.js.map +1 -1
- package/dist/test/decoratorlist.test.js +59 -36
- package/dist/test/decoratorlist.test.js.map +1 -1
- package/dist/test/dundermethoddeclaration.test.js +7 -4
- package/dist/test/dundermethoddeclaration.test.js.map +1 -1
- package/dist/test/enums.test.js +161 -159
- package/dist/test/enums.test.js.map +1 -1
- package/dist/test/externals.test.js +24 -24
- package/dist/test/externals.test.js.map +1 -1
- package/dist/test/factories.test.js +75 -33
- package/dist/test/factories.test.js.map +1 -1
- package/dist/test/functioncallexpressions.test.js +117 -106
- package/dist/test/functioncallexpressions.test.js.map +1 -1
- package/dist/test/functiondeclaration.test.js +247 -180
- package/dist/test/functiondeclaration.test.js.map +1 -1
- package/dist/test/imports.test.js +171 -143
- package/dist/test/imports.test.js.map +1 -1
- package/dist/test/memberexpressions.test.js +582 -453
- package/dist/test/memberexpressions.test.js.map +1 -1
- package/dist/test/methoddeclaration.test.js +66 -46
- package/dist/test/methoddeclaration.test.js.map +1 -1
- package/dist/test/namepolicies.test.js +90 -78
- package/dist/test/namepolicies.test.js.map +1 -1
- package/dist/test/propertydeclaration.test.js +25 -20
- package/dist/test/propertydeclaration.test.js.map +1 -1
- package/dist/test/pydanticclassdeclarations.test.js +134 -190
- package/dist/test/pydanticclassdeclarations.test.js.map +1 -1
- package/dist/test/pydocs.test.js +573 -532
- package/dist/test/pydocs.test.js.map +1 -1
- package/dist/test/references.test.js +31 -28
- package/dist/test/references.test.js.map +1 -1
- package/dist/test/sourcefiles.test.js +700 -580
- package/dist/test/sourcefiles.test.js.map +1 -1
- package/dist/test/staticmethoddeclaration.test.js +7 -4
- package/dist/test/staticmethoddeclaration.test.js.map +1 -1
- package/dist/test/type-checking-imports.test.js +297 -284
- package/dist/test/type-checking-imports.test.js.map +1 -1
- package/dist/test/typereference.test.js +29 -22
- package/dist/test/typereference.test.js.map +1 -1
- package/dist/test/uniontypeexpression.test.js +124 -88
- package/dist/test/uniontypeexpression.test.js.map +1 -1
- package/dist/test/utils.d.ts +10 -17
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +32 -74
- package/dist/test/utils.js.map +1 -1
- package/dist/test/values.test.js +135 -67
- package/dist/test/values.test.js.map +1 -1
- package/dist/test/variables.test.js +201 -151
- package/dist/test/variables.test.js.map +1 -1
- package/dist/test/vitest.setup.d.ts +2 -0
- package/dist/test/vitest.setup.d.ts.map +1 -0
- package/dist/test/vitest.setup.js +2 -0
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/api/components/SourceFile.md +20 -8
- package/package.json +2 -2
- package/src/components/SourceFile.tsx +6 -1
- package/temp/api.json +16 -2
- package/test/callsignatures.test.tsx +309 -283
- package/test/class-method-declaration.test.tsx +3 -4
- package/test/classdeclarations.test.tsx +263 -248
- package/test/classinstantiations.test.tsx +115 -109
- package/test/constructordeclaration.test.tsx +9 -6
- package/test/dataclassdeclarations.test.tsx +243 -361
- package/test/decoratorlist.test.tsx +78 -59
- package/test/dundermethoddeclaration.test.tsx +3 -4
- package/test/enums.test.tsx +65 -81
- package/test/externals.test.tsx +25 -25
- package/test/factories.test.tsx +64 -22
- package/test/functioncallexpressions.test.tsx +123 -109
- package/test/functiondeclaration.test.tsx +209 -148
- package/test/imports.test.tsx +119 -91
- package/test/memberexpressions.test.tsx +265 -207
- package/test/methoddeclaration.test.tsx +84 -63
- package/test/namepolicies.test.tsx +69 -69
- package/test/propertydeclaration.test.tsx +7 -8
- package/test/pydanticclassdeclarations.test.tsx +355 -487
- package/test/pydocs.test.tsx +531 -579
- package/test/references.test.tsx +24 -23
- package/test/sourcefiles.test.tsx +527 -492
- package/test/staticmethoddeclaration.test.tsx +3 -4
- package/test/type-checking-imports.test.tsx +206 -218
- package/test/typereference.test.tsx +15 -12
- package/test/uniontypeexpression.test.tsx +74 -61
- package/test/utils.tsx +26 -110
- package/test/values.test.tsx +82 -32
- package/test/variables.test.tsx +162 -142
- package/test/vitest.setup.ts +1 -0
- package/vitest.config.ts +3 -0
|
@@ -1,328 +1,336 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { Prose } from "@alloy-js/core";
|
|
3
|
-
import { d } from "@alloy-js/core/testing";
|
|
4
3
|
import { expect, it } from "vitest";
|
|
5
4
|
import * as py from "../src/index.js";
|
|
6
5
|
import { dataclassesModule } from "../src/index.js";
|
|
7
|
-
import {
|
|
6
|
+
import { TestOutput, TestOutputDirectory } from "./utils.js";
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* TestOutputDirectory wraps content in an Output component without a default
|
|
10
|
+
* SourceFile, so SourceFile components with their own path/props can be used.
|
|
12
11
|
*/
|
|
13
12
|
it("renders an empty source file", () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
expect(_$createComponent(TestOutput, {}, {
|
|
14
|
+
fileName: import.meta.url,
|
|
15
|
+
lineNumber: 12,
|
|
16
|
+
columnNumber: 10
|
|
17
|
+
})).toRenderTo(`
|
|
17
18
|
|
|
18
19
|
`);
|
|
19
20
|
});
|
|
20
21
|
it("correct formatting of source file", () => {
|
|
21
|
-
|
|
22
|
-
name: "someClass",
|
|
22
|
+
expect(_$createComponent(TestOutput, {
|
|
23
23
|
get children() {
|
|
24
|
-
return _$createComponent(py.
|
|
24
|
+
return [_$createComponent(py.ClassDeclaration, {
|
|
25
|
+
name: "someClass",
|
|
25
26
|
get children() {
|
|
26
|
-
return
|
|
27
|
-
name: "someMethod",
|
|
28
|
-
returnType: "str",
|
|
27
|
+
return _$createComponent(py.StatementList, {
|
|
29
28
|
get children() {
|
|
30
|
-
return _$createComponent(py.
|
|
29
|
+
return [_$createComponent(py.FunctionDeclaration, {
|
|
30
|
+
name: "someMethod",
|
|
31
|
+
returnType: "str",
|
|
31
32
|
get children() {
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
return _$createComponent(py.StatementList, {
|
|
34
|
+
get children() {
|
|
35
|
+
return [_$createComponent(py.VariableDeclaration, {
|
|
36
|
+
name: "x",
|
|
37
|
+
type: "int",
|
|
38
|
+
get initializer() {
|
|
39
|
+
return _$createComponent(py.Atom, {
|
|
40
|
+
jsValue: 42
|
|
41
|
+
}, {
|
|
42
|
+
fileName: import.meta.url,
|
|
43
|
+
lineNumber: 29,
|
|
44
|
+
columnNumber: 30
|
|
45
|
+
});
|
|
46
|
+
}
|
|
38
47
|
}, {
|
|
39
48
|
fileName: import.meta.url,
|
|
40
|
-
lineNumber:
|
|
41
|
-
columnNumber:
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
lineNumber: 26,
|
|
50
|
+
columnNumber: 15
|
|
51
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
52
|
+
name: "y",
|
|
53
|
+
type: "int",
|
|
54
|
+
get initializer() {
|
|
55
|
+
return _$createComponent(py.Atom, {
|
|
56
|
+
jsValue: 42
|
|
57
|
+
}, {
|
|
58
|
+
fileName: import.meta.url,
|
|
59
|
+
lineNumber: 34,
|
|
60
|
+
columnNumber: 30
|
|
61
|
+
});
|
|
62
|
+
}
|
|
54
63
|
}, {
|
|
55
64
|
fileName: import.meta.url,
|
|
56
|
-
lineNumber:
|
|
57
|
-
columnNumber:
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
fileName: import.meta.url,
|
|
62
|
-
lineNumber: 31,
|
|
63
|
-
columnNumber: 13
|
|
64
|
-
}), _$createComponent(py.FunctionCallExpression, {
|
|
65
|
-
target: "foo",
|
|
66
|
-
args: ["a", "b"]
|
|
67
|
-
}, {
|
|
68
|
-
fileName: import.meta.url,
|
|
69
|
-
lineNumber: 36,
|
|
70
|
-
columnNumber: 13
|
|
71
|
-
}), _$createComponent(py.MemberExpression, {
|
|
72
|
-
get children() {
|
|
73
|
-
return [_$createComponent(py.MemberExpression.Part, {
|
|
74
|
-
id: "a"
|
|
65
|
+
lineNumber: 31,
|
|
66
|
+
columnNumber: 15
|
|
67
|
+
}), _$createComponent(py.FunctionCallExpression, {
|
|
68
|
+
target: "foo",
|
|
69
|
+
args: ["a", "b"]
|
|
75
70
|
}, {
|
|
76
71
|
fileName: import.meta.url,
|
|
77
|
-
lineNumber:
|
|
72
|
+
lineNumber: 36,
|
|
78
73
|
columnNumber: 15
|
|
79
|
-
}), _$createComponent(py.MemberExpression
|
|
80
|
-
|
|
74
|
+
}), _$createComponent(py.MemberExpression, {
|
|
75
|
+
get children() {
|
|
76
|
+
return [_$createComponent(py.MemberExpression.Part, {
|
|
77
|
+
id: "a"
|
|
78
|
+
}, {
|
|
79
|
+
fileName: import.meta.url,
|
|
80
|
+
lineNumber: 38,
|
|
81
|
+
columnNumber: 17
|
|
82
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
83
|
+
id: "b"
|
|
84
|
+
}, {
|
|
85
|
+
fileName: import.meta.url,
|
|
86
|
+
lineNumber: 39,
|
|
87
|
+
columnNumber: 17
|
|
88
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
89
|
+
key: "special-prop"
|
|
90
|
+
}, {
|
|
91
|
+
fileName: import.meta.url,
|
|
92
|
+
lineNumber: 40,
|
|
93
|
+
columnNumber: 17
|
|
94
|
+
})];
|
|
95
|
+
}
|
|
81
96
|
}, {
|
|
82
97
|
fileName: import.meta.url,
|
|
83
|
-
lineNumber:
|
|
98
|
+
lineNumber: 37,
|
|
84
99
|
columnNumber: 15
|
|
85
|
-
}), _$createComponent(py.
|
|
86
|
-
|
|
100
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
101
|
+
name: "z",
|
|
102
|
+
type: "int",
|
|
103
|
+
get initializer() {
|
|
104
|
+
return _$createComponent(py.Atom, {
|
|
105
|
+
jsValue: 42
|
|
106
|
+
}, {
|
|
107
|
+
fileName: import.meta.url,
|
|
108
|
+
lineNumber: 45,
|
|
109
|
+
columnNumber: 30
|
|
110
|
+
});
|
|
111
|
+
}
|
|
87
112
|
}, {
|
|
88
113
|
fileName: import.meta.url,
|
|
89
|
-
lineNumber:
|
|
114
|
+
lineNumber: 42,
|
|
90
115
|
columnNumber: 15
|
|
91
116
|
})];
|
|
92
117
|
}
|
|
93
118
|
}, {
|
|
94
119
|
fileName: import.meta.url,
|
|
95
|
-
lineNumber:
|
|
120
|
+
lineNumber: 25,
|
|
96
121
|
columnNumber: 13
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
fileName: import.meta.url,
|
|
126
|
+
lineNumber: 24,
|
|
127
|
+
columnNumber: 11
|
|
128
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
129
|
+
name: "someVar",
|
|
130
|
+
type: "int",
|
|
131
|
+
get initializer() {
|
|
132
|
+
return _$createComponent(py.Atom, {
|
|
133
|
+
jsValue: 42
|
|
109
134
|
}, {
|
|
110
135
|
fileName: import.meta.url,
|
|
111
|
-
lineNumber:
|
|
112
|
-
columnNumber:
|
|
113
|
-
})
|
|
136
|
+
lineNumber: 52,
|
|
137
|
+
columnNumber: 26
|
|
138
|
+
});
|
|
114
139
|
}
|
|
115
140
|
}, {
|
|
116
141
|
fileName: import.meta.url,
|
|
117
|
-
lineNumber:
|
|
142
|
+
lineNumber: 49,
|
|
118
143
|
columnNumber: 11
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
fileName: import.meta.url,
|
|
123
|
-
lineNumber: 24,
|
|
124
|
-
columnNumber: 9
|
|
125
|
-
}), _$createComponent(py.VariableDeclaration, {
|
|
126
|
-
name: "someVar",
|
|
127
|
-
type: "int",
|
|
128
|
-
get initializer() {
|
|
129
|
-
return _$createComponent(py.Atom, {
|
|
130
|
-
jsValue: 42
|
|
144
|
+
}), _$createComponent(py.FunctionDeclaration, {
|
|
145
|
+
name: "someOtherMethod",
|
|
146
|
+
returnType: "str"
|
|
131
147
|
}, {
|
|
132
148
|
fileName: import.meta.url,
|
|
133
|
-
lineNumber:
|
|
134
|
-
columnNumber:
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
columnNumber: 9
|
|
148
|
-
}), _$createComponent(py.VariableDeclaration, {
|
|
149
|
-
name: "someOtherVar",
|
|
150
|
-
type: "int",
|
|
151
|
-
get initializer() {
|
|
152
|
-
return _$createComponent(py.Atom, {
|
|
153
|
-
jsValue: 42
|
|
149
|
+
lineNumber: 54,
|
|
150
|
+
columnNumber: 11
|
|
151
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
152
|
+
name: "someOtherVar",
|
|
153
|
+
type: "int",
|
|
154
|
+
get initializer() {
|
|
155
|
+
return _$createComponent(py.Atom, {
|
|
156
|
+
jsValue: 42
|
|
157
|
+
}, {
|
|
158
|
+
fileName: import.meta.url,
|
|
159
|
+
lineNumber: 58,
|
|
160
|
+
columnNumber: 26
|
|
161
|
+
});
|
|
162
|
+
}
|
|
154
163
|
}, {
|
|
155
164
|
fileName: import.meta.url,
|
|
156
|
-
lineNumber:
|
|
157
|
-
columnNumber:
|
|
158
|
-
});
|
|
165
|
+
lineNumber: 55,
|
|
166
|
+
columnNumber: 11
|
|
167
|
+
})];
|
|
159
168
|
}
|
|
160
169
|
}, {
|
|
161
170
|
fileName: import.meta.url,
|
|
162
|
-
lineNumber:
|
|
171
|
+
lineNumber: 23,
|
|
163
172
|
columnNumber: 9
|
|
164
|
-
})
|
|
173
|
+
});
|
|
165
174
|
}
|
|
166
175
|
}, {
|
|
167
176
|
fileName: import.meta.url,
|
|
168
|
-
lineNumber:
|
|
177
|
+
lineNumber: 22,
|
|
169
178
|
columnNumber: 7
|
|
170
|
-
})
|
|
171
|
-
|
|
172
|
-
}, {
|
|
173
|
-
fileName: import.meta.url,
|
|
174
|
-
lineNumber: 22,
|
|
175
|
-
columnNumber: 5
|
|
176
|
-
}), _$createComponent(py.FunctionDeclaration, {
|
|
177
|
-
name: "someFunction",
|
|
178
|
-
get children() {
|
|
179
|
-
return _$createComponent(py.StatementList, {
|
|
179
|
+
}), _$createComponent(py.FunctionDeclaration, {
|
|
180
|
+
name: "someFunction",
|
|
180
181
|
get children() {
|
|
181
|
-
return
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
return _$createComponent(py.StatementList, {
|
|
183
|
+
get children() {
|
|
184
|
+
return [_$createComponent(py.VariableDeclaration, {
|
|
185
|
+
name: "x",
|
|
186
|
+
type: "int",
|
|
187
|
+
get initializer() {
|
|
188
|
+
return _$createComponent(py.Atom, {
|
|
189
|
+
jsValue: 42
|
|
190
|
+
}, {
|
|
191
|
+
fileName: import.meta.url,
|
|
192
|
+
lineNumber: 67,
|
|
193
|
+
columnNumber: 26
|
|
194
|
+
});
|
|
195
|
+
}
|
|
187
196
|
}, {
|
|
188
197
|
fileName: import.meta.url,
|
|
189
|
-
lineNumber:
|
|
190
|
-
columnNumber:
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
198
|
+
lineNumber: 64,
|
|
199
|
+
columnNumber: 11
|
|
200
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
201
|
+
name: "y",
|
|
202
|
+
type: "int",
|
|
203
|
+
get initializer() {
|
|
204
|
+
return _$createComponent(py.Atom, {
|
|
205
|
+
jsValue: 42
|
|
206
|
+
}, {
|
|
207
|
+
fileName: import.meta.url,
|
|
208
|
+
lineNumber: 72,
|
|
209
|
+
columnNumber: 26
|
|
210
|
+
});
|
|
211
|
+
}
|
|
203
212
|
}, {
|
|
204
213
|
fileName: import.meta.url,
|
|
205
|
-
lineNumber:
|
|
206
|
-
columnNumber:
|
|
207
|
-
})
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
fileName: import.meta.url,
|
|
211
|
-
lineNumber: 69,
|
|
212
|
-
columnNumber: 9
|
|
213
|
-
}), _$createComponent(py.FunctionCallExpression, {
|
|
214
|
-
target: "foo",
|
|
215
|
-
args: ["a", "b"]
|
|
216
|
-
}, {
|
|
217
|
-
fileName: import.meta.url,
|
|
218
|
-
lineNumber: 74,
|
|
219
|
-
columnNumber: 9
|
|
220
|
-
}), _$createComponent(py.MemberExpression, {
|
|
221
|
-
get children() {
|
|
222
|
-
return [_$createComponent(py.MemberExpression.Part, {
|
|
223
|
-
id: "a"
|
|
214
|
+
lineNumber: 69,
|
|
215
|
+
columnNumber: 11
|
|
216
|
+
}), _$createComponent(py.FunctionCallExpression, {
|
|
217
|
+
target: "foo",
|
|
218
|
+
args: ["a", "b"]
|
|
224
219
|
}, {
|
|
225
220
|
fileName: import.meta.url,
|
|
226
|
-
lineNumber:
|
|
221
|
+
lineNumber: 74,
|
|
227
222
|
columnNumber: 11
|
|
228
|
-
}), _$createComponent(py.MemberExpression
|
|
229
|
-
|
|
223
|
+
}), _$createComponent(py.MemberExpression, {
|
|
224
|
+
get children() {
|
|
225
|
+
return [_$createComponent(py.MemberExpression.Part, {
|
|
226
|
+
id: "a"
|
|
227
|
+
}, {
|
|
228
|
+
fileName: import.meta.url,
|
|
229
|
+
lineNumber: 76,
|
|
230
|
+
columnNumber: 13
|
|
231
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
232
|
+
id: "b"
|
|
233
|
+
}, {
|
|
234
|
+
fileName: import.meta.url,
|
|
235
|
+
lineNumber: 77,
|
|
236
|
+
columnNumber: 13
|
|
237
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
238
|
+
key: "special-prop"
|
|
239
|
+
}, {
|
|
240
|
+
fileName: import.meta.url,
|
|
241
|
+
lineNumber: 78,
|
|
242
|
+
columnNumber: 13
|
|
243
|
+
})];
|
|
244
|
+
}
|
|
230
245
|
}, {
|
|
231
246
|
fileName: import.meta.url,
|
|
232
|
-
lineNumber:
|
|
247
|
+
lineNumber: 75,
|
|
233
248
|
columnNumber: 11
|
|
234
|
-
}), _$createComponent(py.
|
|
235
|
-
|
|
249
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
250
|
+
name: "z",
|
|
251
|
+
type: "int",
|
|
252
|
+
get initializer() {
|
|
253
|
+
return _$createComponent(py.Atom, {
|
|
254
|
+
jsValue: 42
|
|
255
|
+
}, {
|
|
256
|
+
fileName: import.meta.url,
|
|
257
|
+
lineNumber: 83,
|
|
258
|
+
columnNumber: 26
|
|
259
|
+
});
|
|
260
|
+
}
|
|
236
261
|
}, {
|
|
237
262
|
fileName: import.meta.url,
|
|
238
|
-
lineNumber:
|
|
263
|
+
lineNumber: 80,
|
|
239
264
|
columnNumber: 11
|
|
240
265
|
})];
|
|
241
266
|
}
|
|
242
267
|
}, {
|
|
243
268
|
fileName: import.meta.url,
|
|
244
|
-
lineNumber:
|
|
269
|
+
lineNumber: 63,
|
|
245
270
|
columnNumber: 9
|
|
246
|
-
})
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}, {
|
|
274
|
+
fileName: import.meta.url,
|
|
275
|
+
lineNumber: 62,
|
|
276
|
+
columnNumber: 7
|
|
277
|
+
}), _$createComponent(py.ClassDeclaration, {
|
|
278
|
+
name: "someOtherClass",
|
|
279
|
+
get children() {
|
|
280
|
+
return _$createComponent(py.StatementList, {
|
|
281
|
+
get children() {
|
|
282
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
283
|
+
name: "someMethod",
|
|
284
|
+
returnType: "str"
|
|
252
285
|
}, {
|
|
253
286
|
fileName: import.meta.url,
|
|
254
|
-
lineNumber:
|
|
255
|
-
columnNumber:
|
|
287
|
+
lineNumber: 89,
|
|
288
|
+
columnNumber: 11
|
|
256
289
|
});
|
|
257
290
|
}
|
|
258
291
|
}, {
|
|
259
292
|
fileName: import.meta.url,
|
|
260
|
-
lineNumber:
|
|
293
|
+
lineNumber: 88,
|
|
261
294
|
columnNumber: 9
|
|
262
|
-
})
|
|
295
|
+
});
|
|
263
296
|
}
|
|
264
297
|
}, {
|
|
265
298
|
fileName: import.meta.url,
|
|
266
|
-
lineNumber:
|
|
299
|
+
lineNumber: 87,
|
|
267
300
|
columnNumber: 7
|
|
268
|
-
})
|
|
269
|
-
}
|
|
270
|
-
}, {
|
|
271
|
-
fileName: import.meta.url,
|
|
272
|
-
lineNumber: 62,
|
|
273
|
-
columnNumber: 5
|
|
274
|
-
}), _$createComponent(py.ClassDeclaration, {
|
|
275
|
-
name: "someOtherClass",
|
|
276
|
-
get children() {
|
|
277
|
-
return _$createComponent(py.StatementList, {
|
|
301
|
+
}), _$createComponent(py.MemberExpression, {
|
|
278
302
|
get children() {
|
|
279
|
-
return _$createComponent(py.
|
|
280
|
-
|
|
281
|
-
returnType: "str"
|
|
303
|
+
return [_$createComponent(py.MemberExpression.Part, {
|
|
304
|
+
id: "a"
|
|
282
305
|
}, {
|
|
283
306
|
fileName: import.meta.url,
|
|
284
|
-
lineNumber:
|
|
307
|
+
lineNumber: 93,
|
|
285
308
|
columnNumber: 9
|
|
286
|
-
})
|
|
309
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
310
|
+
id: "b"
|
|
311
|
+
}, {
|
|
312
|
+
fileName: import.meta.url,
|
|
313
|
+
lineNumber: 94,
|
|
314
|
+
columnNumber: 9
|
|
315
|
+
}), _$createComponent(py.MemberExpression.Part, {
|
|
316
|
+
key: "special-prop"
|
|
317
|
+
}, {
|
|
318
|
+
fileName: import.meta.url,
|
|
319
|
+
lineNumber: 95,
|
|
320
|
+
columnNumber: 9
|
|
321
|
+
})];
|
|
287
322
|
}
|
|
288
323
|
}, {
|
|
289
324
|
fileName: import.meta.url,
|
|
290
|
-
lineNumber:
|
|
291
|
-
columnNumber: 7
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
}, {
|
|
295
|
-
fileName: import.meta.url,
|
|
296
|
-
lineNumber: 87,
|
|
297
|
-
columnNumber: 5
|
|
298
|
-
}), _$createComponent(py.MemberExpression, {
|
|
299
|
-
get children() {
|
|
300
|
-
return [_$createComponent(py.MemberExpression.Part, {
|
|
301
|
-
id: "a"
|
|
302
|
-
}, {
|
|
303
|
-
fileName: import.meta.url,
|
|
304
|
-
lineNumber: 93,
|
|
305
|
-
columnNumber: 7
|
|
306
|
-
}), _$createComponent(py.MemberExpression.Part, {
|
|
307
|
-
id: "b"
|
|
308
|
-
}, {
|
|
309
|
-
fileName: import.meta.url,
|
|
310
|
-
lineNumber: 94,
|
|
311
|
-
columnNumber: 7
|
|
312
|
-
}), _$createComponent(py.MemberExpression.Part, {
|
|
313
|
-
key: "special-prop"
|
|
314
|
-
}, {
|
|
315
|
-
fileName: import.meta.url,
|
|
316
|
-
lineNumber: 95,
|
|
325
|
+
lineNumber: 92,
|
|
317
326
|
columnNumber: 7
|
|
318
327
|
})];
|
|
319
328
|
}
|
|
320
329
|
}, {
|
|
321
330
|
fileName: import.meta.url,
|
|
322
|
-
lineNumber:
|
|
331
|
+
lineNumber: 21,
|
|
323
332
|
columnNumber: 5
|
|
324
|
-
})
|
|
325
|
-
expect(result).toRenderTo(d`
|
|
333
|
+
})).toRenderTo(`
|
|
326
334
|
class SomeClass:
|
|
327
335
|
def some_method() -> str:
|
|
328
336
|
x: int = 42
|
|
@@ -353,7 +361,6 @@ it("correct formatting of source file", () => {
|
|
|
353
361
|
|
|
354
362
|
|
|
355
363
|
a.b["special-prop"]
|
|
356
|
-
|
|
357
364
|
`);
|
|
358
365
|
});
|
|
359
366
|
it("renders module documentation correctly", () => {
|
|
@@ -363,7 +370,7 @@ it("renders module documentation correctly", () => {
|
|
|
363
370
|
children: "This module provides utility functions for data processing. It includes functions for validation, transformation, and analysis."
|
|
364
371
|
}, {
|
|
365
372
|
fileName: import.meta.url,
|
|
366
|
-
lineNumber:
|
|
373
|
+
lineNumber: 138,
|
|
367
374
|
columnNumber: 9
|
|
368
375
|
})];
|
|
369
376
|
},
|
|
@@ -380,42 +387,50 @@ it("renders module documentation correctly", () => {
|
|
|
380
387
|
style: "google"
|
|
381
388
|
}, {
|
|
382
389
|
fileName: import.meta.url,
|
|
383
|
-
lineNumber:
|
|
390
|
+
lineNumber: 136,
|
|
384
391
|
columnNumber: 5
|
|
385
392
|
});
|
|
386
|
-
|
|
387
|
-
path: "test.py",
|
|
388
|
-
doc: moduleDoc,
|
|
393
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
389
394
|
get children() {
|
|
390
|
-
return
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
395
|
+
return _$createComponent(py.SourceFile, {
|
|
396
|
+
path: "test.py",
|
|
397
|
+
doc: moduleDoc,
|
|
398
|
+
get children() {
|
|
399
|
+
return [_$createComponent(py.VariableDeclaration, {
|
|
400
|
+
name: "DEFAULT_TIMEOUT",
|
|
401
|
+
initializer: 30
|
|
402
|
+
}, {
|
|
403
|
+
fileName: import.meta.url,
|
|
404
|
+
lineNumber: 163,
|
|
405
|
+
columnNumber: 9
|
|
406
|
+
}), _$createComponent(py.VariableDeclaration, {
|
|
407
|
+
name: "MAX_RETRIES",
|
|
408
|
+
initializer: 3
|
|
409
|
+
}, {
|
|
410
|
+
fileName: import.meta.url,
|
|
411
|
+
lineNumber: 164,
|
|
412
|
+
columnNumber: 9
|
|
413
|
+
}), _$createComponent(py.FunctionDeclaration, {
|
|
414
|
+
name: "process_data",
|
|
415
|
+
children: "pass"
|
|
416
|
+
}, {
|
|
417
|
+
fileName: import.meta.url,
|
|
418
|
+
lineNumber: 165,
|
|
419
|
+
columnNumber: 9
|
|
420
|
+
})];
|
|
421
|
+
}
|
|
400
422
|
}, {
|
|
401
423
|
fileName: import.meta.url,
|
|
402
424
|
lineNumber: 162,
|
|
403
425
|
columnNumber: 7
|
|
404
|
-
})
|
|
405
|
-
name: "process_data",
|
|
406
|
-
children: "pass"
|
|
407
|
-
}, {
|
|
408
|
-
fileName: import.meta.url,
|
|
409
|
-
lineNumber: 163,
|
|
410
|
-
columnNumber: 7
|
|
411
|
-
})];
|
|
426
|
+
});
|
|
412
427
|
}
|
|
413
428
|
}, {
|
|
414
429
|
fileName: import.meta.url,
|
|
415
|
-
lineNumber:
|
|
430
|
+
lineNumber: 161,
|
|
416
431
|
columnNumber: 5
|
|
417
|
-
})
|
|
418
|
-
|
|
432
|
+
})).toRenderTo({
|
|
433
|
+
"test.py": `
|
|
419
434
|
"""
|
|
420
435
|
This module provides utility functions for data processing. It includes
|
|
421
436
|
functions for validation, transformation, and analysis.
|
|
@@ -437,78 +452,103 @@ it("renders module documentation correctly", () => {
|
|
|
437
452
|
def process_data():
|
|
438
453
|
pass
|
|
439
454
|
|
|
440
|
-
|
|
441
|
-
|
|
455
|
+
`
|
|
456
|
+
});
|
|
442
457
|
});
|
|
443
458
|
it("renders source file without documentation correctly", () => {
|
|
444
|
-
|
|
445
|
-
path: "test.py",
|
|
459
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
446
460
|
get children() {
|
|
447
|
-
return _$createComponent(py.
|
|
448
|
-
|
|
449
|
-
children
|
|
461
|
+
return _$createComponent(py.SourceFile, {
|
|
462
|
+
path: "test.py",
|
|
463
|
+
get children() {
|
|
464
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
465
|
+
name: "hello_world",
|
|
466
|
+
children: "print(\"Hello, World!\")"
|
|
467
|
+
}, {
|
|
468
|
+
fileName: import.meta.url,
|
|
469
|
+
lineNumber: 201,
|
|
470
|
+
columnNumber: 9
|
|
471
|
+
});
|
|
472
|
+
}
|
|
450
473
|
}, {
|
|
451
474
|
fileName: import.meta.url,
|
|
452
|
-
lineNumber:
|
|
475
|
+
lineNumber: 200,
|
|
453
476
|
columnNumber: 7
|
|
454
477
|
});
|
|
455
478
|
}
|
|
456
479
|
}, {
|
|
457
480
|
fileName: import.meta.url,
|
|
458
|
-
lineNumber:
|
|
481
|
+
lineNumber: 199,
|
|
459
482
|
columnNumber: 5
|
|
460
|
-
})
|
|
461
|
-
|
|
483
|
+
})).toRenderTo({
|
|
484
|
+
"test.py": `
|
|
462
485
|
def hello_world():
|
|
463
486
|
print("Hello, World!")
|
|
464
487
|
|
|
465
|
-
|
|
466
|
-
|
|
488
|
+
`
|
|
489
|
+
});
|
|
467
490
|
});
|
|
468
491
|
it("nothing before top-level definition", () => {
|
|
469
|
-
|
|
470
|
-
path: "test.py",
|
|
492
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
471
493
|
get children() {
|
|
472
|
-
return _$createComponent(py.
|
|
473
|
-
|
|
474
|
-
children
|
|
494
|
+
return _$createComponent(py.SourceFile, {
|
|
495
|
+
path: "test.py",
|
|
496
|
+
get children() {
|
|
497
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
498
|
+
name: "hello",
|
|
499
|
+
children: "pass"
|
|
500
|
+
}, {
|
|
501
|
+
fileName: import.meta.url,
|
|
502
|
+
lineNumber: 219,
|
|
503
|
+
columnNumber: 9
|
|
504
|
+
});
|
|
505
|
+
}
|
|
475
506
|
}, {
|
|
476
507
|
fileName: import.meta.url,
|
|
477
|
-
lineNumber:
|
|
508
|
+
lineNumber: 218,
|
|
478
509
|
columnNumber: 7
|
|
479
510
|
});
|
|
480
511
|
}
|
|
481
512
|
}, {
|
|
482
513
|
fileName: import.meta.url,
|
|
483
|
-
lineNumber:
|
|
514
|
+
lineNumber: 217,
|
|
484
515
|
columnNumber: 5
|
|
485
|
-
})
|
|
486
|
-
|
|
516
|
+
})).toRenderTo({
|
|
517
|
+
"test.py": `
|
|
487
518
|
def hello():
|
|
488
519
|
pass
|
|
489
520
|
|
|
490
|
-
|
|
491
|
-
|
|
521
|
+
`
|
|
522
|
+
});
|
|
492
523
|
});
|
|
493
524
|
it("nothing before non-definition", () => {
|
|
494
|
-
|
|
495
|
-
path: "test.py",
|
|
525
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
496
526
|
get children() {
|
|
497
|
-
return _$createComponent(py.
|
|
498
|
-
|
|
499
|
-
|
|
527
|
+
return _$createComponent(py.SourceFile, {
|
|
528
|
+
path: "test.py",
|
|
529
|
+
get children() {
|
|
530
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
531
|
+
name: "x",
|
|
532
|
+
initializer: 42
|
|
533
|
+
}, {
|
|
534
|
+
fileName: import.meta.url,
|
|
535
|
+
lineNumber: 235,
|
|
536
|
+
columnNumber: 9
|
|
537
|
+
});
|
|
538
|
+
}
|
|
500
539
|
}, {
|
|
501
540
|
fileName: import.meta.url,
|
|
502
|
-
lineNumber:
|
|
541
|
+
lineNumber: 234,
|
|
503
542
|
columnNumber: 7
|
|
504
543
|
});
|
|
505
544
|
}
|
|
506
545
|
}, {
|
|
507
546
|
fileName: import.meta.url,
|
|
508
|
-
lineNumber:
|
|
547
|
+
lineNumber: 233,
|
|
509
548
|
columnNumber: 5
|
|
549
|
+
})).toRenderTo({
|
|
550
|
+
"test.py": "x = 42"
|
|
510
551
|
});
|
|
511
|
-
expect(toSourceText(content)).toRenderTo("x = 42");
|
|
512
552
|
});
|
|
513
553
|
it("only doc before definition", () => {
|
|
514
554
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -517,34 +557,42 @@ it("only doc before definition", () => {
|
|
|
517
557
|
children: "Module description."
|
|
518
558
|
}, {
|
|
519
559
|
fileName: import.meta.url,
|
|
520
|
-
lineNumber:
|
|
560
|
+
lineNumber: 243,
|
|
521
561
|
columnNumber: 33
|
|
522
562
|
})];
|
|
523
563
|
}
|
|
524
564
|
}, {
|
|
525
565
|
fileName: import.meta.url,
|
|
526
|
-
lineNumber:
|
|
566
|
+
lineNumber: 243,
|
|
527
567
|
columnNumber: 5
|
|
528
568
|
});
|
|
529
|
-
|
|
530
|
-
path: "test.py",
|
|
531
|
-
doc: moduleDoc,
|
|
569
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
532
570
|
get children() {
|
|
533
|
-
return _$createComponent(py.
|
|
534
|
-
|
|
535
|
-
|
|
571
|
+
return _$createComponent(py.SourceFile, {
|
|
572
|
+
path: "test.py",
|
|
573
|
+
doc: moduleDoc,
|
|
574
|
+
get children() {
|
|
575
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
576
|
+
name: "hello",
|
|
577
|
+
children: "pass"
|
|
578
|
+
}, {
|
|
579
|
+
fileName: import.meta.url,
|
|
580
|
+
lineNumber: 249,
|
|
581
|
+
columnNumber: 9
|
|
582
|
+
});
|
|
583
|
+
}
|
|
536
584
|
}, {
|
|
537
585
|
fileName: import.meta.url,
|
|
538
|
-
lineNumber:
|
|
586
|
+
lineNumber: 248,
|
|
539
587
|
columnNumber: 7
|
|
540
588
|
});
|
|
541
589
|
}
|
|
542
590
|
}, {
|
|
543
591
|
fileName: import.meta.url,
|
|
544
|
-
lineNumber:
|
|
592
|
+
lineNumber: 247,
|
|
545
593
|
columnNumber: 5
|
|
546
|
-
})
|
|
547
|
-
|
|
594
|
+
})).toRenderTo({
|
|
595
|
+
"test.py": `
|
|
548
596
|
"""
|
|
549
597
|
Module description.
|
|
550
598
|
"""
|
|
@@ -553,8 +601,8 @@ it("only doc before definition", () => {
|
|
|
553
601
|
def hello():
|
|
554
602
|
pass
|
|
555
603
|
|
|
556
|
-
|
|
557
|
-
|
|
604
|
+
`
|
|
605
|
+
});
|
|
558
606
|
});
|
|
559
607
|
it("only doc before non-definition", () => {
|
|
560
608
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -563,196 +611,242 @@ it("only doc before non-definition", () => {
|
|
|
563
611
|
children: "Module description."
|
|
564
612
|
}, {
|
|
565
613
|
fileName: import.meta.url,
|
|
566
|
-
lineNumber:
|
|
614
|
+
lineNumber: 268,
|
|
567
615
|
columnNumber: 33
|
|
568
616
|
})];
|
|
569
617
|
}
|
|
570
618
|
}, {
|
|
571
619
|
fileName: import.meta.url,
|
|
572
|
-
lineNumber:
|
|
620
|
+
lineNumber: 268,
|
|
573
621
|
columnNumber: 5
|
|
574
622
|
});
|
|
575
|
-
|
|
576
|
-
path: "test.py",
|
|
577
|
-
doc: moduleDoc,
|
|
623
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
578
624
|
get children() {
|
|
579
|
-
return _$createComponent(py.
|
|
580
|
-
|
|
581
|
-
|
|
625
|
+
return _$createComponent(py.SourceFile, {
|
|
626
|
+
path: "test.py",
|
|
627
|
+
doc: moduleDoc,
|
|
628
|
+
get children() {
|
|
629
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
630
|
+
name: "x",
|
|
631
|
+
initializer: 42
|
|
632
|
+
}, {
|
|
633
|
+
fileName: import.meta.url,
|
|
634
|
+
lineNumber: 274,
|
|
635
|
+
columnNumber: 9
|
|
636
|
+
});
|
|
637
|
+
}
|
|
582
638
|
}, {
|
|
583
639
|
fileName: import.meta.url,
|
|
584
|
-
lineNumber:
|
|
640
|
+
lineNumber: 273,
|
|
585
641
|
columnNumber: 7
|
|
586
642
|
});
|
|
587
643
|
}
|
|
588
644
|
}, {
|
|
589
645
|
fileName: import.meta.url,
|
|
590
|
-
lineNumber:
|
|
646
|
+
lineNumber: 272,
|
|
591
647
|
columnNumber: 5
|
|
592
|
-
})
|
|
593
|
-
|
|
648
|
+
})).toRenderTo({
|
|
649
|
+
"test.py": `
|
|
594
650
|
"""
|
|
595
651
|
Module description.
|
|
596
652
|
"""
|
|
597
653
|
|
|
598
|
-
x = 42`
|
|
654
|
+
x = 42`
|
|
655
|
+
});
|
|
599
656
|
});
|
|
600
657
|
it("only header before definition", () => {
|
|
601
|
-
|
|
602
|
-
path: "test.py",
|
|
603
|
-
header: "#!/usr/bin/env python3",
|
|
658
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
604
659
|
get children() {
|
|
605
|
-
return _$createComponent(py.
|
|
606
|
-
|
|
607
|
-
|
|
660
|
+
return _$createComponent(py.SourceFile, {
|
|
661
|
+
path: "test.py",
|
|
662
|
+
header: "#!/usr/bin/env python3",
|
|
663
|
+
get children() {
|
|
664
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
665
|
+
name: "hello",
|
|
666
|
+
children: "pass"
|
|
667
|
+
}, {
|
|
668
|
+
fileName: import.meta.url,
|
|
669
|
+
lineNumber: 291,
|
|
670
|
+
columnNumber: 9
|
|
671
|
+
});
|
|
672
|
+
}
|
|
608
673
|
}, {
|
|
609
674
|
fileName: import.meta.url,
|
|
610
|
-
lineNumber:
|
|
675
|
+
lineNumber: 290,
|
|
611
676
|
columnNumber: 7
|
|
612
677
|
});
|
|
613
678
|
}
|
|
614
679
|
}, {
|
|
615
680
|
fileName: import.meta.url,
|
|
616
|
-
lineNumber:
|
|
681
|
+
lineNumber: 289,
|
|
617
682
|
columnNumber: 5
|
|
618
|
-
})
|
|
619
|
-
|
|
620
|
-
// 2 blank lines before definition (PEP 8)
|
|
621
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
683
|
+
})).toRenderTo({
|
|
684
|
+
"test.py": `
|
|
622
685
|
#!/usr/bin/env python3
|
|
623
686
|
|
|
624
687
|
|
|
625
688
|
def hello():
|
|
626
689
|
pass
|
|
627
690
|
|
|
628
|
-
|
|
629
|
-
|
|
691
|
+
`
|
|
692
|
+
});
|
|
630
693
|
});
|
|
631
694
|
it("only header before non-definition", () => {
|
|
632
|
-
|
|
633
|
-
path: "test.py",
|
|
634
|
-
header: "#!/usr/bin/env python3",
|
|
695
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
635
696
|
get children() {
|
|
636
|
-
return _$createComponent(py.
|
|
637
|
-
|
|
638
|
-
|
|
697
|
+
return _$createComponent(py.SourceFile, {
|
|
698
|
+
path: "test.py",
|
|
699
|
+
header: "#!/usr/bin/env python3",
|
|
700
|
+
get children() {
|
|
701
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
702
|
+
name: "x",
|
|
703
|
+
initializer: 42
|
|
704
|
+
}, {
|
|
705
|
+
fileName: import.meta.url,
|
|
706
|
+
lineNumber: 310,
|
|
707
|
+
columnNumber: 9
|
|
708
|
+
});
|
|
709
|
+
}
|
|
639
710
|
}, {
|
|
640
711
|
fileName: import.meta.url,
|
|
641
|
-
lineNumber:
|
|
712
|
+
lineNumber: 309,
|
|
642
713
|
columnNumber: 7
|
|
643
714
|
});
|
|
644
715
|
}
|
|
645
716
|
}, {
|
|
646
717
|
fileName: import.meta.url,
|
|
647
|
-
lineNumber:
|
|
718
|
+
lineNumber: 308,
|
|
648
719
|
columnNumber: 5
|
|
649
|
-
})
|
|
650
|
-
|
|
651
|
-
// 1 blank line for non-definition
|
|
652
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
720
|
+
})).toRenderTo({
|
|
721
|
+
"test.py": `
|
|
653
722
|
#!/usr/bin/env python3
|
|
654
723
|
|
|
655
|
-
x = 42`
|
|
724
|
+
x = 42`
|
|
725
|
+
});
|
|
656
726
|
});
|
|
657
727
|
it("only futureImports before definition", () => {
|
|
658
|
-
|
|
659
|
-
path: "test.py",
|
|
660
|
-
get futureImports() {
|
|
661
|
-
return [_$createComponent(py.FutureStatement, {
|
|
662
|
-
feature: "annotations"
|
|
663
|
-
}, {
|
|
664
|
-
fileName: import.meta.url,
|
|
665
|
-
lineNumber: 315,
|
|
666
|
-
columnNumber: 23
|
|
667
|
-
})];
|
|
668
|
-
},
|
|
728
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
669
729
|
get children() {
|
|
670
|
-
return _$createComponent(py.
|
|
671
|
-
|
|
672
|
-
|
|
730
|
+
return _$createComponent(py.SourceFile, {
|
|
731
|
+
path: "test.py",
|
|
732
|
+
get futureImports() {
|
|
733
|
+
return [_$createComponent(py.FutureStatement, {
|
|
734
|
+
feature: "annotations"
|
|
735
|
+
}, {
|
|
736
|
+
fileName: import.meta.url,
|
|
737
|
+
lineNumber: 326,
|
|
738
|
+
columnNumber: 25
|
|
739
|
+
})];
|
|
740
|
+
},
|
|
741
|
+
get children() {
|
|
742
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
743
|
+
name: "hello",
|
|
744
|
+
children: "pass"
|
|
745
|
+
}, {
|
|
746
|
+
fileName: import.meta.url,
|
|
747
|
+
lineNumber: 328,
|
|
748
|
+
columnNumber: 9
|
|
749
|
+
});
|
|
750
|
+
}
|
|
673
751
|
}, {
|
|
674
752
|
fileName: import.meta.url,
|
|
675
|
-
lineNumber:
|
|
753
|
+
lineNumber: 324,
|
|
676
754
|
columnNumber: 7
|
|
677
755
|
});
|
|
678
756
|
}
|
|
679
757
|
}, {
|
|
680
758
|
fileName: import.meta.url,
|
|
681
|
-
lineNumber:
|
|
759
|
+
lineNumber: 323,
|
|
682
760
|
columnNumber: 5
|
|
683
|
-
})
|
|
684
|
-
|
|
761
|
+
})).toRenderTo({
|
|
762
|
+
"test.py": `
|
|
685
763
|
from __future__ import annotations
|
|
686
764
|
|
|
687
765
|
|
|
688
766
|
def hello():
|
|
689
767
|
pass
|
|
690
768
|
|
|
691
|
-
|
|
692
|
-
|
|
769
|
+
`
|
|
770
|
+
});
|
|
693
771
|
});
|
|
694
772
|
it("only futureImports before non-definition", () => {
|
|
695
|
-
|
|
696
|
-
path: "test.py",
|
|
697
|
-
get futureImports() {
|
|
698
|
-
return [_$createComponent(py.FutureStatement, {
|
|
699
|
-
feature: "annotations"
|
|
700
|
-
}, {
|
|
701
|
-
fileName: import.meta.url,
|
|
702
|
-
lineNumber: 336,
|
|
703
|
-
columnNumber: 23
|
|
704
|
-
})];
|
|
705
|
-
},
|
|
773
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
706
774
|
get children() {
|
|
707
|
-
return _$createComponent(py.
|
|
708
|
-
|
|
709
|
-
|
|
775
|
+
return _$createComponent(py.SourceFile, {
|
|
776
|
+
path: "test.py",
|
|
777
|
+
get futureImports() {
|
|
778
|
+
return [_$createComponent(py.FutureStatement, {
|
|
779
|
+
feature: "annotations"
|
|
780
|
+
}, {
|
|
781
|
+
fileName: import.meta.url,
|
|
782
|
+
lineNumber: 348,
|
|
783
|
+
columnNumber: 25
|
|
784
|
+
})];
|
|
785
|
+
},
|
|
786
|
+
get children() {
|
|
787
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
788
|
+
name: "x",
|
|
789
|
+
initializer: 42
|
|
790
|
+
}, {
|
|
791
|
+
fileName: import.meta.url,
|
|
792
|
+
lineNumber: 350,
|
|
793
|
+
columnNumber: 9
|
|
794
|
+
});
|
|
795
|
+
}
|
|
710
796
|
}, {
|
|
711
797
|
fileName: import.meta.url,
|
|
712
|
-
lineNumber:
|
|
798
|
+
lineNumber: 346,
|
|
713
799
|
columnNumber: 7
|
|
714
800
|
});
|
|
715
801
|
}
|
|
716
802
|
}, {
|
|
717
803
|
fileName: import.meta.url,
|
|
718
|
-
lineNumber:
|
|
804
|
+
lineNumber: 345,
|
|
719
805
|
columnNumber: 5
|
|
720
|
-
})
|
|
721
|
-
|
|
806
|
+
})).toRenderTo({
|
|
807
|
+
"test.py": `
|
|
722
808
|
from __future__ import annotations
|
|
723
809
|
|
|
724
|
-
x = 42`
|
|
810
|
+
x = 42`
|
|
811
|
+
});
|
|
725
812
|
});
|
|
726
813
|
it("only imports before definition", () => {
|
|
727
|
-
|
|
728
|
-
|
|
814
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
815
|
+
externals: [dataclassesModule],
|
|
729
816
|
get children() {
|
|
730
|
-
return _$createComponent(py.
|
|
731
|
-
|
|
817
|
+
return _$createComponent(py.SourceFile, {
|
|
818
|
+
path: "test.py",
|
|
732
819
|
get children() {
|
|
733
|
-
return _$createComponent(py.
|
|
734
|
-
name: "
|
|
735
|
-
|
|
820
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
821
|
+
name: "User",
|
|
822
|
+
get children() {
|
|
823
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
824
|
+
name: "name",
|
|
825
|
+
type: "str"
|
|
826
|
+
}, {
|
|
827
|
+
fileName: import.meta.url,
|
|
828
|
+
lineNumber: 366,
|
|
829
|
+
columnNumber: 11
|
|
830
|
+
});
|
|
831
|
+
}
|
|
736
832
|
}, {
|
|
737
833
|
fileName: import.meta.url,
|
|
738
|
-
lineNumber:
|
|
834
|
+
lineNumber: 365,
|
|
739
835
|
columnNumber: 9
|
|
740
836
|
});
|
|
741
837
|
}
|
|
742
838
|
}, {
|
|
743
839
|
fileName: import.meta.url,
|
|
744
|
-
lineNumber:
|
|
840
|
+
lineNumber: 364,
|
|
745
841
|
columnNumber: 7
|
|
746
842
|
});
|
|
747
843
|
}
|
|
748
844
|
}, {
|
|
749
845
|
fileName: import.meta.url,
|
|
750
|
-
lineNumber:
|
|
846
|
+
lineNumber: 363,
|
|
751
847
|
columnNumber: 5
|
|
752
|
-
})
|
|
753
|
-
|
|
754
|
-
externals: [dataclassesModule]
|
|
755
|
-
})).toRenderTo(d`
|
|
848
|
+
})).toRenderTo({
|
|
849
|
+
"test.py": `
|
|
756
850
|
from dataclasses import dataclass
|
|
757
851
|
|
|
758
852
|
|
|
@@ -760,43 +854,51 @@ it("only imports before definition", () => {
|
|
|
760
854
|
class User:
|
|
761
855
|
name: str = None
|
|
762
856
|
|
|
763
|
-
|
|
764
|
-
|
|
857
|
+
`
|
|
858
|
+
});
|
|
765
859
|
});
|
|
766
860
|
it("only imports before non-definition", () => {
|
|
767
|
-
|
|
768
|
-
|
|
861
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
862
|
+
externals: [dataclassesModule],
|
|
769
863
|
get children() {
|
|
770
|
-
return _$createComponent(py.
|
|
771
|
-
|
|
772
|
-
get
|
|
773
|
-
return _$createComponent(py.
|
|
774
|
-
|
|
775
|
-
|
|
864
|
+
return _$createComponent(py.SourceFile, {
|
|
865
|
+
path: "test.py",
|
|
866
|
+
get children() {
|
|
867
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
868
|
+
name: "x",
|
|
869
|
+
get initializer() {
|
|
870
|
+
return _$createComponent(py.Reference, {
|
|
871
|
+
get refkey() {
|
|
872
|
+
return dataclassesModule["."].dataclass;
|
|
873
|
+
}
|
|
874
|
+
}, {
|
|
875
|
+
fileName: import.meta.url,
|
|
876
|
+
lineNumber: 390,
|
|
877
|
+
columnNumber: 13
|
|
878
|
+
});
|
|
776
879
|
}
|
|
777
880
|
}, {
|
|
778
881
|
fileName: import.meta.url,
|
|
779
|
-
lineNumber:
|
|
780
|
-
columnNumber:
|
|
882
|
+
lineNumber: 387,
|
|
883
|
+
columnNumber: 9
|
|
781
884
|
});
|
|
782
885
|
}
|
|
783
886
|
}, {
|
|
784
887
|
fileName: import.meta.url,
|
|
785
|
-
lineNumber:
|
|
888
|
+
lineNumber: 386,
|
|
786
889
|
columnNumber: 7
|
|
787
890
|
});
|
|
788
891
|
}
|
|
789
892
|
}, {
|
|
790
893
|
fileName: import.meta.url,
|
|
791
|
-
lineNumber:
|
|
894
|
+
lineNumber: 385,
|
|
792
895
|
columnNumber: 5
|
|
793
|
-
})
|
|
794
|
-
|
|
795
|
-
externals: [dataclassesModule]
|
|
796
|
-
})).toRenderTo(d`
|
|
896
|
+
})).toRenderTo({
|
|
897
|
+
"test.py": `
|
|
797
898
|
from dataclasses import dataclass
|
|
798
899
|
|
|
799
|
-
x = dataclass`
|
|
900
|
+
x = dataclass`
|
|
901
|
+
});
|
|
800
902
|
});
|
|
801
903
|
it("doc + futureImports before definition", () => {
|
|
802
904
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -805,43 +907,51 @@ it("doc + futureImports before definition", () => {
|
|
|
805
907
|
children: "Module description."
|
|
806
908
|
}, {
|
|
807
909
|
fileName: import.meta.url,
|
|
808
|
-
lineNumber:
|
|
910
|
+
lineNumber: 405,
|
|
809
911
|
columnNumber: 33
|
|
810
912
|
})];
|
|
811
913
|
}
|
|
812
914
|
}, {
|
|
813
915
|
fileName: import.meta.url,
|
|
814
|
-
lineNumber:
|
|
916
|
+
lineNumber: 405,
|
|
815
917
|
columnNumber: 5
|
|
816
918
|
});
|
|
817
|
-
|
|
818
|
-
path: "test.py",
|
|
819
|
-
doc: moduleDoc,
|
|
820
|
-
get futureImports() {
|
|
821
|
-
return [_$createComponent(py.FutureStatement, {
|
|
822
|
-
feature: "annotations"
|
|
823
|
-
}, {
|
|
824
|
-
fileName: import.meta.url,
|
|
825
|
-
lineNumber: 396,
|
|
826
|
-
columnNumber: 23
|
|
827
|
-
})];
|
|
828
|
-
},
|
|
919
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
829
920
|
get children() {
|
|
830
|
-
return _$createComponent(py.
|
|
831
|
-
|
|
832
|
-
|
|
921
|
+
return _$createComponent(py.SourceFile, {
|
|
922
|
+
path: "test.py",
|
|
923
|
+
doc: moduleDoc,
|
|
924
|
+
get futureImports() {
|
|
925
|
+
return [_$createComponent(py.FutureStatement, {
|
|
926
|
+
feature: "annotations"
|
|
927
|
+
}, {
|
|
928
|
+
fileName: import.meta.url,
|
|
929
|
+
lineNumber: 413,
|
|
930
|
+
columnNumber: 25
|
|
931
|
+
})];
|
|
932
|
+
},
|
|
933
|
+
get children() {
|
|
934
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
935
|
+
name: "hello",
|
|
936
|
+
children: "pass"
|
|
937
|
+
}, {
|
|
938
|
+
fileName: import.meta.url,
|
|
939
|
+
lineNumber: 415,
|
|
940
|
+
columnNumber: 9
|
|
941
|
+
});
|
|
942
|
+
}
|
|
833
943
|
}, {
|
|
834
944
|
fileName: import.meta.url,
|
|
835
|
-
lineNumber:
|
|
945
|
+
lineNumber: 410,
|
|
836
946
|
columnNumber: 7
|
|
837
947
|
});
|
|
838
948
|
}
|
|
839
949
|
}, {
|
|
840
950
|
fileName: import.meta.url,
|
|
841
|
-
lineNumber:
|
|
951
|
+
lineNumber: 409,
|
|
842
952
|
columnNumber: 5
|
|
843
|
-
})
|
|
844
|
-
|
|
953
|
+
})).toRenderTo({
|
|
954
|
+
"test.py": `
|
|
845
955
|
"""
|
|
846
956
|
Module description.
|
|
847
957
|
"""
|
|
@@ -852,8 +962,8 @@ it("doc + futureImports before definition", () => {
|
|
|
852
962
|
def hello():
|
|
853
963
|
pass
|
|
854
964
|
|
|
855
|
-
|
|
856
|
-
|
|
965
|
+
`
|
|
966
|
+
});
|
|
857
967
|
});
|
|
858
968
|
it("doc + futureImports before non-definition", () => {
|
|
859
969
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -862,50 +972,59 @@ it("doc + futureImports before non-definition", () => {
|
|
|
862
972
|
children: "Module description."
|
|
863
973
|
}, {
|
|
864
974
|
fileName: import.meta.url,
|
|
865
|
-
lineNumber:
|
|
975
|
+
lineNumber: 436,
|
|
866
976
|
columnNumber: 33
|
|
867
977
|
})];
|
|
868
978
|
}
|
|
869
979
|
}, {
|
|
870
980
|
fileName: import.meta.url,
|
|
871
|
-
lineNumber:
|
|
981
|
+
lineNumber: 436,
|
|
872
982
|
columnNumber: 5
|
|
873
983
|
});
|
|
874
|
-
|
|
875
|
-
path: "test.py",
|
|
876
|
-
doc: moduleDoc,
|
|
877
|
-
get futureImports() {
|
|
878
|
-
return [_$createComponent(py.FutureStatement, {
|
|
879
|
-
feature: "annotations"
|
|
880
|
-
}, {
|
|
881
|
-
fileName: import.meta.url,
|
|
882
|
-
lineNumber: 426,
|
|
883
|
-
columnNumber: 23
|
|
884
|
-
})];
|
|
885
|
-
},
|
|
984
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
886
985
|
get children() {
|
|
887
|
-
return _$createComponent(py.
|
|
888
|
-
|
|
889
|
-
|
|
986
|
+
return _$createComponent(py.SourceFile, {
|
|
987
|
+
path: "test.py",
|
|
988
|
+
doc: moduleDoc,
|
|
989
|
+
get futureImports() {
|
|
990
|
+
return [_$createComponent(py.FutureStatement, {
|
|
991
|
+
feature: "annotations"
|
|
992
|
+
}, {
|
|
993
|
+
fileName: import.meta.url,
|
|
994
|
+
lineNumber: 444,
|
|
995
|
+
columnNumber: 25
|
|
996
|
+
})];
|
|
997
|
+
},
|
|
998
|
+
get children() {
|
|
999
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1000
|
+
name: "x",
|
|
1001
|
+
initializer: 42
|
|
1002
|
+
}, {
|
|
1003
|
+
fileName: import.meta.url,
|
|
1004
|
+
lineNumber: 446,
|
|
1005
|
+
columnNumber: 9
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
890
1008
|
}, {
|
|
891
1009
|
fileName: import.meta.url,
|
|
892
|
-
lineNumber:
|
|
1010
|
+
lineNumber: 441,
|
|
893
1011
|
columnNumber: 7
|
|
894
1012
|
});
|
|
895
1013
|
}
|
|
896
1014
|
}, {
|
|
897
1015
|
fileName: import.meta.url,
|
|
898
|
-
lineNumber:
|
|
1016
|
+
lineNumber: 440,
|
|
899
1017
|
columnNumber: 5
|
|
900
|
-
})
|
|
901
|
-
|
|
1018
|
+
})).toRenderTo({
|
|
1019
|
+
"test.py": `
|
|
902
1020
|
"""
|
|
903
1021
|
Module description.
|
|
904
1022
|
"""
|
|
905
1023
|
|
|
906
1024
|
from __future__ import annotations
|
|
907
1025
|
|
|
908
|
-
x = 42`
|
|
1026
|
+
x = 42`
|
|
1027
|
+
});
|
|
909
1028
|
});
|
|
910
1029
|
it("doc + imports before definition", () => {
|
|
911
1030
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -914,45 +1033,52 @@ it("doc + imports before definition", () => {
|
|
|
914
1033
|
children: "Module description."
|
|
915
1034
|
}, {
|
|
916
1035
|
fileName: import.meta.url,
|
|
917
|
-
lineNumber:
|
|
1036
|
+
lineNumber: 463,
|
|
918
1037
|
columnNumber: 33
|
|
919
1038
|
})];
|
|
920
1039
|
}
|
|
921
1040
|
}, {
|
|
922
1041
|
fileName: import.meta.url,
|
|
923
|
-
lineNumber:
|
|
1042
|
+
lineNumber: 463,
|
|
924
1043
|
columnNumber: 5
|
|
925
1044
|
});
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
doc: moduleDoc,
|
|
1045
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1046
|
+
externals: [dataclassesModule],
|
|
929
1047
|
get children() {
|
|
930
|
-
return _$createComponent(py.
|
|
931
|
-
|
|
1048
|
+
return _$createComponent(py.SourceFile, {
|
|
1049
|
+
path: "test.py",
|
|
1050
|
+
doc: moduleDoc,
|
|
932
1051
|
get children() {
|
|
933
|
-
return _$createComponent(py.
|
|
934
|
-
name: "
|
|
935
|
-
|
|
1052
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
1053
|
+
name: "User",
|
|
1054
|
+
get children() {
|
|
1055
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1056
|
+
name: "name",
|
|
1057
|
+
type: "str"
|
|
1058
|
+
}, {
|
|
1059
|
+
fileName: import.meta.url,
|
|
1060
|
+
lineNumber: 470,
|
|
1061
|
+
columnNumber: 11
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
936
1064
|
}, {
|
|
937
1065
|
fileName: import.meta.url,
|
|
938
|
-
lineNumber:
|
|
1066
|
+
lineNumber: 469,
|
|
939
1067
|
columnNumber: 9
|
|
940
1068
|
});
|
|
941
1069
|
}
|
|
942
1070
|
}, {
|
|
943
1071
|
fileName: import.meta.url,
|
|
944
|
-
lineNumber:
|
|
1072
|
+
lineNumber: 468,
|
|
945
1073
|
columnNumber: 7
|
|
946
1074
|
});
|
|
947
1075
|
}
|
|
948
1076
|
}, {
|
|
949
1077
|
fileName: import.meta.url,
|
|
950
|
-
lineNumber:
|
|
1078
|
+
lineNumber: 467,
|
|
951
1079
|
columnNumber: 5
|
|
952
|
-
})
|
|
953
|
-
|
|
954
|
-
externals: [dataclassesModule]
|
|
955
|
-
})).toRenderTo(d`
|
|
1080
|
+
})).toRenderTo({
|
|
1081
|
+
"test.py": `
|
|
956
1082
|
"""
|
|
957
1083
|
Module description.
|
|
958
1084
|
"""
|
|
@@ -964,8 +1090,8 @@ it("doc + imports before definition", () => {
|
|
|
964
1090
|
class User:
|
|
965
1091
|
name: str = None
|
|
966
1092
|
|
|
967
|
-
|
|
968
|
-
|
|
1093
|
+
`
|
|
1094
|
+
});
|
|
969
1095
|
});
|
|
970
1096
|
it("doc + imports before non-definition", () => {
|
|
971
1097
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -974,93 +1100,108 @@ it("doc + imports before non-definition", () => {
|
|
|
974
1100
|
children: "Module description."
|
|
975
1101
|
}, {
|
|
976
1102
|
fileName: import.meta.url,
|
|
977
|
-
lineNumber:
|
|
1103
|
+
lineNumber: 493,
|
|
978
1104
|
columnNumber: 33
|
|
979
1105
|
})];
|
|
980
1106
|
}
|
|
981
1107
|
}, {
|
|
982
1108
|
fileName: import.meta.url,
|
|
983
|
-
lineNumber:
|
|
1109
|
+
lineNumber: 493,
|
|
984
1110
|
columnNumber: 5
|
|
985
1111
|
});
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
doc: moduleDoc,
|
|
1112
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1113
|
+
externals: [dataclassesModule],
|
|
989
1114
|
get children() {
|
|
990
|
-
return _$createComponent(py.
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1115
|
+
return _$createComponent(py.SourceFile, {
|
|
1116
|
+
path: "test.py",
|
|
1117
|
+
doc: moduleDoc,
|
|
1118
|
+
get children() {
|
|
1119
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1120
|
+
name: "x",
|
|
1121
|
+
get initializer() {
|
|
1122
|
+
return _$createComponent(py.Reference, {
|
|
1123
|
+
get refkey() {
|
|
1124
|
+
return dataclassesModule["."].dataclass;
|
|
1125
|
+
}
|
|
1126
|
+
}, {
|
|
1127
|
+
fileName: import.meta.url,
|
|
1128
|
+
lineNumber: 502,
|
|
1129
|
+
columnNumber: 13
|
|
1130
|
+
});
|
|
996
1131
|
}
|
|
997
1132
|
}, {
|
|
998
1133
|
fileName: import.meta.url,
|
|
999
|
-
lineNumber:
|
|
1000
|
-
columnNumber:
|
|
1134
|
+
lineNumber: 499,
|
|
1135
|
+
columnNumber: 9
|
|
1001
1136
|
});
|
|
1002
1137
|
}
|
|
1003
1138
|
}, {
|
|
1004
1139
|
fileName: import.meta.url,
|
|
1005
|
-
lineNumber:
|
|
1140
|
+
lineNumber: 498,
|
|
1006
1141
|
columnNumber: 7
|
|
1007
1142
|
});
|
|
1008
1143
|
}
|
|
1009
1144
|
}, {
|
|
1010
1145
|
fileName: import.meta.url,
|
|
1011
|
-
lineNumber:
|
|
1146
|
+
lineNumber: 497,
|
|
1012
1147
|
columnNumber: 5
|
|
1013
|
-
})
|
|
1014
|
-
|
|
1015
|
-
externals: [dataclassesModule]
|
|
1016
|
-
})).toRenderTo(d`
|
|
1148
|
+
})).toRenderTo({
|
|
1149
|
+
"test.py": `
|
|
1017
1150
|
"""
|
|
1018
1151
|
Module description.
|
|
1019
1152
|
"""
|
|
1020
1153
|
|
|
1021
1154
|
from dataclasses import dataclass
|
|
1022
1155
|
|
|
1023
|
-
x = dataclass`
|
|
1156
|
+
x = dataclass`
|
|
1157
|
+
});
|
|
1024
1158
|
});
|
|
1025
1159
|
it("futureImports + imports before definition", () => {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
get futureImports() {
|
|
1029
|
-
return [_$createComponent(py.FutureStatement, {
|
|
1030
|
-
feature: "annotations"
|
|
1031
|
-
}, {
|
|
1032
|
-
fileName: import.meta.url,
|
|
1033
|
-
lineNumber: 501,
|
|
1034
|
-
columnNumber: 23
|
|
1035
|
-
})];
|
|
1036
|
-
},
|
|
1160
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1161
|
+
externals: [dataclassesModule],
|
|
1037
1162
|
get children() {
|
|
1038
|
-
return _$createComponent(py.
|
|
1039
|
-
|
|
1163
|
+
return _$createComponent(py.SourceFile, {
|
|
1164
|
+
path: "test.py",
|
|
1165
|
+
get futureImports() {
|
|
1166
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1167
|
+
feature: "annotations"
|
|
1168
|
+
}, {
|
|
1169
|
+
fileName: import.meta.url,
|
|
1170
|
+
lineNumber: 524,
|
|
1171
|
+
columnNumber: 25
|
|
1172
|
+
})];
|
|
1173
|
+
},
|
|
1040
1174
|
get children() {
|
|
1041
|
-
return _$createComponent(py.
|
|
1042
|
-
name: "
|
|
1043
|
-
|
|
1175
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
1176
|
+
name: "User",
|
|
1177
|
+
get children() {
|
|
1178
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1179
|
+
name: "name",
|
|
1180
|
+
type: "str"
|
|
1181
|
+
}, {
|
|
1182
|
+
fileName: import.meta.url,
|
|
1183
|
+
lineNumber: 527,
|
|
1184
|
+
columnNumber: 11
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1044
1187
|
}, {
|
|
1045
1188
|
fileName: import.meta.url,
|
|
1046
|
-
lineNumber:
|
|
1189
|
+
lineNumber: 526,
|
|
1047
1190
|
columnNumber: 9
|
|
1048
1191
|
});
|
|
1049
1192
|
}
|
|
1050
1193
|
}, {
|
|
1051
1194
|
fileName: import.meta.url,
|
|
1052
|
-
lineNumber:
|
|
1195
|
+
lineNumber: 522,
|
|
1053
1196
|
columnNumber: 7
|
|
1054
1197
|
});
|
|
1055
1198
|
}
|
|
1056
1199
|
}, {
|
|
1057
1200
|
fileName: import.meta.url,
|
|
1058
|
-
lineNumber:
|
|
1201
|
+
lineNumber: 521,
|
|
1059
1202
|
columnNumber: 5
|
|
1060
|
-
})
|
|
1061
|
-
|
|
1062
|
-
externals: [dataclassesModule]
|
|
1063
|
-
})).toRenderTo(d`
|
|
1203
|
+
})).toRenderTo({
|
|
1204
|
+
"test.py": `
|
|
1064
1205
|
from __future__ import annotations
|
|
1065
1206
|
|
|
1066
1207
|
from dataclasses import dataclass
|
|
@@ -1070,54 +1211,62 @@ it("futureImports + imports before definition", () => {
|
|
|
1070
1211
|
class User:
|
|
1071
1212
|
name: str = None
|
|
1072
1213
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1214
|
+
`
|
|
1215
|
+
});
|
|
1075
1216
|
});
|
|
1076
1217
|
it("futureImports + imports before non-definition", () => {
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
get futureImports() {
|
|
1080
|
-
return [_$createComponent(py.FutureStatement, {
|
|
1081
|
-
feature: "annotations"
|
|
1082
|
-
}, {
|
|
1083
|
-
fileName: import.meta.url,
|
|
1084
|
-
lineNumber: 528,
|
|
1085
|
-
columnNumber: 23
|
|
1086
|
-
})];
|
|
1087
|
-
},
|
|
1218
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1219
|
+
externals: [dataclassesModule],
|
|
1088
1220
|
get children() {
|
|
1089
|
-
return _$createComponent(py.
|
|
1090
|
-
|
|
1091
|
-
get
|
|
1092
|
-
return _$createComponent(py.
|
|
1093
|
-
|
|
1094
|
-
|
|
1221
|
+
return _$createComponent(py.SourceFile, {
|
|
1222
|
+
path: "test.py",
|
|
1223
|
+
get futureImports() {
|
|
1224
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1225
|
+
feature: "annotations"
|
|
1226
|
+
}, {
|
|
1227
|
+
fileName: import.meta.url,
|
|
1228
|
+
lineNumber: 551,
|
|
1229
|
+
columnNumber: 25
|
|
1230
|
+
})];
|
|
1231
|
+
},
|
|
1232
|
+
get children() {
|
|
1233
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1234
|
+
name: "x",
|
|
1235
|
+
get initializer() {
|
|
1236
|
+
return _$createComponent(py.Reference, {
|
|
1237
|
+
get refkey() {
|
|
1238
|
+
return dataclassesModule["."].dataclass;
|
|
1239
|
+
}
|
|
1240
|
+
}, {
|
|
1241
|
+
fileName: import.meta.url,
|
|
1242
|
+
lineNumber: 556,
|
|
1243
|
+
columnNumber: 13
|
|
1244
|
+
});
|
|
1095
1245
|
}
|
|
1096
1246
|
}, {
|
|
1097
1247
|
fileName: import.meta.url,
|
|
1098
|
-
lineNumber:
|
|
1099
|
-
columnNumber:
|
|
1248
|
+
lineNumber: 553,
|
|
1249
|
+
columnNumber: 9
|
|
1100
1250
|
});
|
|
1101
1251
|
}
|
|
1102
1252
|
}, {
|
|
1103
1253
|
fileName: import.meta.url,
|
|
1104
|
-
lineNumber:
|
|
1254
|
+
lineNumber: 549,
|
|
1105
1255
|
columnNumber: 7
|
|
1106
1256
|
});
|
|
1107
1257
|
}
|
|
1108
1258
|
}, {
|
|
1109
1259
|
fileName: import.meta.url,
|
|
1110
|
-
lineNumber:
|
|
1260
|
+
lineNumber: 548,
|
|
1111
1261
|
columnNumber: 5
|
|
1112
|
-
})
|
|
1113
|
-
|
|
1114
|
-
externals: [dataclassesModule]
|
|
1115
|
-
})).toRenderTo(d`
|
|
1262
|
+
})).toRenderTo({
|
|
1263
|
+
"test.py": `
|
|
1116
1264
|
from __future__ import annotations
|
|
1117
1265
|
|
|
1118
1266
|
from dataclasses import dataclass
|
|
1119
1267
|
|
|
1120
|
-
x = dataclass`
|
|
1268
|
+
x = dataclass`
|
|
1269
|
+
});
|
|
1121
1270
|
});
|
|
1122
1271
|
it("doc + futureImports + imports before definition", () => {
|
|
1123
1272
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -1126,54 +1275,61 @@ it("doc + futureImports + imports before definition", () => {
|
|
|
1126
1275
|
children: "Module description."
|
|
1127
1276
|
}, {
|
|
1128
1277
|
fileName: import.meta.url,
|
|
1129
|
-
lineNumber:
|
|
1278
|
+
lineNumber: 573,
|
|
1130
1279
|
columnNumber: 33
|
|
1131
1280
|
})];
|
|
1132
1281
|
}
|
|
1133
1282
|
}, {
|
|
1134
1283
|
fileName: import.meta.url,
|
|
1135
|
-
lineNumber:
|
|
1284
|
+
lineNumber: 573,
|
|
1136
1285
|
columnNumber: 5
|
|
1137
1286
|
});
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
doc: moduleDoc,
|
|
1141
|
-
get futureImports() {
|
|
1142
|
-
return [_$createComponent(py.FutureStatement, {
|
|
1143
|
-
feature: "annotations"
|
|
1144
|
-
}, {
|
|
1145
|
-
fileName: import.meta.url,
|
|
1146
|
-
lineNumber: 555,
|
|
1147
|
-
columnNumber: 23
|
|
1148
|
-
})];
|
|
1149
|
-
},
|
|
1287
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1288
|
+
externals: [dataclassesModule],
|
|
1150
1289
|
get children() {
|
|
1151
|
-
return _$createComponent(py.
|
|
1152
|
-
|
|
1290
|
+
return _$createComponent(py.SourceFile, {
|
|
1291
|
+
path: "test.py",
|
|
1292
|
+
doc: moduleDoc,
|
|
1293
|
+
get futureImports() {
|
|
1294
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1295
|
+
feature: "annotations"
|
|
1296
|
+
}, {
|
|
1297
|
+
fileName: import.meta.url,
|
|
1298
|
+
lineNumber: 581,
|
|
1299
|
+
columnNumber: 25
|
|
1300
|
+
})];
|
|
1301
|
+
},
|
|
1153
1302
|
get children() {
|
|
1154
|
-
return _$createComponent(py.
|
|
1155
|
-
name: "
|
|
1156
|
-
|
|
1303
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
1304
|
+
name: "User",
|
|
1305
|
+
get children() {
|
|
1306
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1307
|
+
name: "name",
|
|
1308
|
+
type: "str"
|
|
1309
|
+
}, {
|
|
1310
|
+
fileName: import.meta.url,
|
|
1311
|
+
lineNumber: 584,
|
|
1312
|
+
columnNumber: 11
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1157
1315
|
}, {
|
|
1158
1316
|
fileName: import.meta.url,
|
|
1159
|
-
lineNumber:
|
|
1317
|
+
lineNumber: 583,
|
|
1160
1318
|
columnNumber: 9
|
|
1161
1319
|
});
|
|
1162
1320
|
}
|
|
1163
1321
|
}, {
|
|
1164
1322
|
fileName: import.meta.url,
|
|
1165
|
-
lineNumber:
|
|
1323
|
+
lineNumber: 578,
|
|
1166
1324
|
columnNumber: 7
|
|
1167
1325
|
});
|
|
1168
1326
|
}
|
|
1169
1327
|
}, {
|
|
1170
1328
|
fileName: import.meta.url,
|
|
1171
|
-
lineNumber:
|
|
1329
|
+
lineNumber: 577,
|
|
1172
1330
|
columnNumber: 5
|
|
1173
|
-
})
|
|
1174
|
-
|
|
1175
|
-
externals: [dataclassesModule]
|
|
1176
|
-
})).toRenderTo(d`
|
|
1331
|
+
})).toRenderTo({
|
|
1332
|
+
"test.py": `
|
|
1177
1333
|
"""
|
|
1178
1334
|
Module description.
|
|
1179
1335
|
"""
|
|
@@ -1187,8 +1343,8 @@ it("doc + futureImports + imports before definition", () => {
|
|
|
1187
1343
|
class User:
|
|
1188
1344
|
name: str = None
|
|
1189
1345
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1346
|
+
`
|
|
1347
|
+
});
|
|
1192
1348
|
});
|
|
1193
1349
|
it("doc + futureImports + imports before non-definition", () => {
|
|
1194
1350
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -1197,55 +1353,62 @@ it("doc + futureImports + imports before non-definition", () => {
|
|
|
1197
1353
|
children: "Module description."
|
|
1198
1354
|
}, {
|
|
1199
1355
|
fileName: import.meta.url,
|
|
1200
|
-
lineNumber:
|
|
1356
|
+
lineNumber: 609,
|
|
1201
1357
|
columnNumber: 33
|
|
1202
1358
|
})];
|
|
1203
1359
|
}
|
|
1204
1360
|
}, {
|
|
1205
1361
|
fileName: import.meta.url,
|
|
1206
|
-
lineNumber:
|
|
1362
|
+
lineNumber: 609,
|
|
1207
1363
|
columnNumber: 5
|
|
1208
1364
|
});
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
doc: moduleDoc,
|
|
1212
|
-
get futureImports() {
|
|
1213
|
-
return [_$createComponent(py.FutureStatement, {
|
|
1214
|
-
feature: "annotations"
|
|
1215
|
-
}, {
|
|
1216
|
-
fileName: import.meta.url,
|
|
1217
|
-
lineNumber: 591,
|
|
1218
|
-
columnNumber: 23
|
|
1219
|
-
})];
|
|
1220
|
-
},
|
|
1365
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1366
|
+
externals: [dataclassesModule],
|
|
1221
1367
|
get children() {
|
|
1222
|
-
return _$createComponent(py.
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1368
|
+
return _$createComponent(py.SourceFile, {
|
|
1369
|
+
path: "test.py",
|
|
1370
|
+
doc: moduleDoc,
|
|
1371
|
+
get futureImports() {
|
|
1372
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1373
|
+
feature: "annotations"
|
|
1374
|
+
}, {
|
|
1375
|
+
fileName: import.meta.url,
|
|
1376
|
+
lineNumber: 617,
|
|
1377
|
+
columnNumber: 25
|
|
1378
|
+
})];
|
|
1379
|
+
},
|
|
1380
|
+
get children() {
|
|
1381
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1382
|
+
name: "x",
|
|
1383
|
+
get initializer() {
|
|
1384
|
+
return _$createComponent(py.Reference, {
|
|
1385
|
+
get refkey() {
|
|
1386
|
+
return dataclassesModule["."].dataclass;
|
|
1387
|
+
}
|
|
1388
|
+
}, {
|
|
1389
|
+
fileName: import.meta.url,
|
|
1390
|
+
lineNumber: 622,
|
|
1391
|
+
columnNumber: 13
|
|
1392
|
+
});
|
|
1228
1393
|
}
|
|
1229
1394
|
}, {
|
|
1230
1395
|
fileName: import.meta.url,
|
|
1231
|
-
lineNumber:
|
|
1232
|
-
columnNumber:
|
|
1396
|
+
lineNumber: 619,
|
|
1397
|
+
columnNumber: 9
|
|
1233
1398
|
});
|
|
1234
1399
|
}
|
|
1235
1400
|
}, {
|
|
1236
1401
|
fileName: import.meta.url,
|
|
1237
|
-
lineNumber:
|
|
1402
|
+
lineNumber: 614,
|
|
1238
1403
|
columnNumber: 7
|
|
1239
1404
|
});
|
|
1240
1405
|
}
|
|
1241
1406
|
}, {
|
|
1242
1407
|
fileName: import.meta.url,
|
|
1243
|
-
lineNumber:
|
|
1408
|
+
lineNumber: 613,
|
|
1244
1409
|
columnNumber: 5
|
|
1245
|
-
})
|
|
1246
|
-
|
|
1247
|
-
externals: [dataclassesModule]
|
|
1248
|
-
})).toRenderTo(d`
|
|
1410
|
+
})).toRenderTo({
|
|
1411
|
+
"test.py": `
|
|
1249
1412
|
"""
|
|
1250
1413
|
Module description.
|
|
1251
1414
|
"""
|
|
@@ -1254,7 +1417,8 @@ it("doc + futureImports + imports before non-definition", () => {
|
|
|
1254
1417
|
|
|
1255
1418
|
from dataclasses import dataclass
|
|
1256
1419
|
|
|
1257
|
-
x = dataclass`
|
|
1420
|
+
x = dataclass`
|
|
1421
|
+
});
|
|
1258
1422
|
});
|
|
1259
1423
|
it("only doc in file (no children)", () => {
|
|
1260
1424
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -1263,67 +1427,89 @@ it("only doc in file (no children)", () => {
|
|
|
1263
1427
|
children: "Module description."
|
|
1264
1428
|
}, {
|
|
1265
1429
|
fileName: import.meta.url,
|
|
1266
|
-
lineNumber:
|
|
1430
|
+
lineNumber: 643,
|
|
1267
1431
|
columnNumber: 33
|
|
1268
1432
|
})];
|
|
1269
1433
|
}
|
|
1270
1434
|
}, {
|
|
1271
1435
|
fileName: import.meta.url,
|
|
1272
|
-
lineNumber:
|
|
1436
|
+
lineNumber: 643,
|
|
1273
1437
|
columnNumber: 5
|
|
1274
1438
|
});
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1439
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1440
|
+
get children() {
|
|
1441
|
+
return _$createComponent(py.SourceFile, {
|
|
1442
|
+
path: "test.py",
|
|
1443
|
+
doc: moduleDoc
|
|
1444
|
+
}, {
|
|
1445
|
+
fileName: import.meta.url,
|
|
1446
|
+
lineNumber: 648,
|
|
1447
|
+
columnNumber: 7
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1278
1450
|
}, {
|
|
1279
1451
|
fileName: import.meta.url,
|
|
1280
|
-
lineNumber:
|
|
1281
|
-
columnNumber:
|
|
1282
|
-
})
|
|
1283
|
-
|
|
1452
|
+
lineNumber: 647,
|
|
1453
|
+
columnNumber: 5
|
|
1454
|
+
})).toRenderTo({
|
|
1455
|
+
"test.py": `
|
|
1284
1456
|
"""
|
|
1285
1457
|
Module description.
|
|
1286
1458
|
"""
|
|
1287
1459
|
|
|
1288
|
-
|
|
1289
|
-
|
|
1460
|
+
`
|
|
1461
|
+
});
|
|
1290
1462
|
});
|
|
1291
1463
|
it("only header in file (no children)", () => {
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1464
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1465
|
+
get children() {
|
|
1466
|
+
return _$createComponent(py.SourceFile, {
|
|
1467
|
+
path: "test.py",
|
|
1468
|
+
header: "#!/usr/bin/env python3"
|
|
1469
|
+
}, {
|
|
1470
|
+
fileName: import.meta.url,
|
|
1471
|
+
lineNumber: 663,
|
|
1472
|
+
columnNumber: 7
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1295
1475
|
}, {
|
|
1296
1476
|
fileName: import.meta.url,
|
|
1297
|
-
lineNumber:
|
|
1477
|
+
lineNumber: 662,
|
|
1298
1478
|
columnNumber: 5
|
|
1299
|
-
})
|
|
1300
|
-
|
|
1479
|
+
})).toRenderTo({
|
|
1480
|
+
"test.py": `
|
|
1301
1481
|
#!/usr/bin/env python3
|
|
1302
1482
|
|
|
1303
|
-
|
|
1304
|
-
|
|
1483
|
+
`
|
|
1484
|
+
});
|
|
1305
1485
|
});
|
|
1306
1486
|
it("only futureImports in file (no children)", () => {
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1487
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1488
|
+
get children() {
|
|
1489
|
+
return _$createComponent(py.SourceFile, {
|
|
1490
|
+
path: "test.py",
|
|
1491
|
+
get futureImports() {
|
|
1492
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1493
|
+
feature: "annotations"
|
|
1494
|
+
}, {
|
|
1495
|
+
fileName: import.meta.url,
|
|
1496
|
+
lineNumber: 678,
|
|
1497
|
+
columnNumber: 25
|
|
1498
|
+
})];
|
|
1499
|
+
}
|
|
1312
1500
|
}, {
|
|
1313
1501
|
fileName: import.meta.url,
|
|
1314
|
-
lineNumber:
|
|
1315
|
-
columnNumber:
|
|
1316
|
-
})
|
|
1502
|
+
lineNumber: 676,
|
|
1503
|
+
columnNumber: 7
|
|
1504
|
+
});
|
|
1317
1505
|
}
|
|
1318
1506
|
}, {
|
|
1319
1507
|
fileName: import.meta.url,
|
|
1320
|
-
lineNumber:
|
|
1508
|
+
lineNumber: 675,
|
|
1321
1509
|
columnNumber: 5
|
|
1510
|
+
})).toRenderTo({
|
|
1511
|
+
"test.py": "from __future__ import annotations"
|
|
1322
1512
|
});
|
|
1323
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1324
|
-
from __future__ import annotations
|
|
1325
|
-
|
|
1326
|
-
`);
|
|
1327
1513
|
});
|
|
1328
1514
|
it("doc + futureImports in file (no children)", () => {
|
|
1329
1515
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -1332,97 +1518,120 @@ it("doc + futureImports in file (no children)", () => {
|
|
|
1332
1518
|
children: "Module description."
|
|
1333
1519
|
}, {
|
|
1334
1520
|
fileName: import.meta.url,
|
|
1335
|
-
lineNumber:
|
|
1521
|
+
lineNumber: 688,
|
|
1336
1522
|
columnNumber: 33
|
|
1337
1523
|
})];
|
|
1338
1524
|
}
|
|
1339
1525
|
}, {
|
|
1340
1526
|
fileName: import.meta.url,
|
|
1341
|
-
lineNumber:
|
|
1527
|
+
lineNumber: 688,
|
|
1342
1528
|
columnNumber: 5
|
|
1343
1529
|
});
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1530
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1531
|
+
get children() {
|
|
1532
|
+
return _$createComponent(py.SourceFile, {
|
|
1533
|
+
path: "test.py",
|
|
1534
|
+
doc: moduleDoc,
|
|
1535
|
+
get futureImports() {
|
|
1536
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1537
|
+
feature: "annotations"
|
|
1538
|
+
}, {
|
|
1539
|
+
fileName: import.meta.url,
|
|
1540
|
+
lineNumber: 696,
|
|
1541
|
+
columnNumber: 25
|
|
1542
|
+
})];
|
|
1543
|
+
}
|
|
1350
1544
|
}, {
|
|
1351
1545
|
fileName: import.meta.url,
|
|
1352
|
-
lineNumber:
|
|
1353
|
-
columnNumber:
|
|
1354
|
-
})
|
|
1546
|
+
lineNumber: 693,
|
|
1547
|
+
columnNumber: 7
|
|
1548
|
+
});
|
|
1355
1549
|
}
|
|
1356
1550
|
}, {
|
|
1357
1551
|
fileName: import.meta.url,
|
|
1358
|
-
lineNumber:
|
|
1552
|
+
lineNumber: 692,
|
|
1359
1553
|
columnNumber: 5
|
|
1360
|
-
})
|
|
1361
|
-
|
|
1554
|
+
})).toRenderTo({
|
|
1555
|
+
"test.py": `
|
|
1362
1556
|
"""
|
|
1363
1557
|
Module description.
|
|
1364
1558
|
"""
|
|
1365
1559
|
|
|
1366
1560
|
from __future__ import annotations
|
|
1367
|
-
|
|
1368
|
-
|
|
1561
|
+
`
|
|
1562
|
+
});
|
|
1369
1563
|
});
|
|
1370
1564
|
|
|
1371
1565
|
// headerComment tests
|
|
1372
1566
|
it("only headerComment before definition", () => {
|
|
1373
|
-
|
|
1374
|
-
path: "test.py",
|
|
1375
|
-
headerComment: "Copyright 2024 My Company",
|
|
1567
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1376
1568
|
get children() {
|
|
1377
|
-
return _$createComponent(py.
|
|
1378
|
-
|
|
1379
|
-
|
|
1569
|
+
return _$createComponent(py.SourceFile, {
|
|
1570
|
+
path: "test.py",
|
|
1571
|
+
headerComment: "Copyright 2024 My Company",
|
|
1572
|
+
get children() {
|
|
1573
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
1574
|
+
name: "hello",
|
|
1575
|
+
children: "pass"
|
|
1576
|
+
}, {
|
|
1577
|
+
fileName: import.meta.url,
|
|
1578
|
+
lineNumber: 715,
|
|
1579
|
+
columnNumber: 9
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1380
1582
|
}, {
|
|
1381
1583
|
fileName: import.meta.url,
|
|
1382
|
-
lineNumber:
|
|
1584
|
+
lineNumber: 714,
|
|
1383
1585
|
columnNumber: 7
|
|
1384
1586
|
});
|
|
1385
1587
|
}
|
|
1386
1588
|
}, {
|
|
1387
1589
|
fileName: import.meta.url,
|
|
1388
|
-
lineNumber:
|
|
1590
|
+
lineNumber: 713,
|
|
1389
1591
|
columnNumber: 5
|
|
1390
|
-
})
|
|
1391
|
-
|
|
1392
|
-
// 2 blank lines before definition (PEP 8)
|
|
1393
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1592
|
+
})).toRenderTo({
|
|
1593
|
+
"test.py": `
|
|
1394
1594
|
# Copyright 2024 My Company
|
|
1395
1595
|
|
|
1396
1596
|
|
|
1397
1597
|
def hello():
|
|
1398
1598
|
pass
|
|
1399
1599
|
|
|
1400
|
-
|
|
1401
|
-
|
|
1600
|
+
`
|
|
1601
|
+
});
|
|
1402
1602
|
});
|
|
1403
1603
|
it("only headerComment before non-definition", () => {
|
|
1404
|
-
|
|
1405
|
-
path: "test.py",
|
|
1406
|
-
headerComment: "Copyright 2024 My Company",
|
|
1604
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1407
1605
|
get children() {
|
|
1408
|
-
return _$createComponent(py.
|
|
1409
|
-
|
|
1410
|
-
|
|
1606
|
+
return _$createComponent(py.SourceFile, {
|
|
1607
|
+
path: "test.py",
|
|
1608
|
+
headerComment: "Copyright 2024 My Company",
|
|
1609
|
+
get children() {
|
|
1610
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1611
|
+
name: "x",
|
|
1612
|
+
initializer: 42
|
|
1613
|
+
}, {
|
|
1614
|
+
fileName: import.meta.url,
|
|
1615
|
+
lineNumber: 734,
|
|
1616
|
+
columnNumber: 9
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1411
1619
|
}, {
|
|
1412
1620
|
fileName: import.meta.url,
|
|
1413
|
-
lineNumber:
|
|
1621
|
+
lineNumber: 733,
|
|
1414
1622
|
columnNumber: 7
|
|
1415
1623
|
});
|
|
1416
1624
|
}
|
|
1417
1625
|
}, {
|
|
1418
1626
|
fileName: import.meta.url,
|
|
1419
|
-
lineNumber:
|
|
1627
|
+
lineNumber: 732,
|
|
1420
1628
|
columnNumber: 5
|
|
1421
|
-
})
|
|
1422
|
-
|
|
1629
|
+
})).toRenderTo({
|
|
1630
|
+
"test.py": `
|
|
1423
1631
|
# Copyright 2024 My Company
|
|
1424
1632
|
|
|
1425
|
-
x = 42`
|
|
1633
|
+
x = 42`
|
|
1634
|
+
});
|
|
1426
1635
|
});
|
|
1427
1636
|
it("headerComment + doc before definition", () => {
|
|
1428
1637
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -1431,37 +1640,43 @@ it("headerComment + doc before definition", () => {
|
|
|
1431
1640
|
children: "Module description."
|
|
1432
1641
|
}, {
|
|
1433
1642
|
fileName: import.meta.url,
|
|
1434
|
-
lineNumber:
|
|
1643
|
+
lineNumber: 747,
|
|
1435
1644
|
columnNumber: 33
|
|
1436
1645
|
})];
|
|
1437
1646
|
}
|
|
1438
1647
|
}, {
|
|
1439
1648
|
fileName: import.meta.url,
|
|
1440
|
-
lineNumber:
|
|
1649
|
+
lineNumber: 747,
|
|
1441
1650
|
columnNumber: 5
|
|
1442
1651
|
});
|
|
1443
|
-
|
|
1444
|
-
path: "test.py",
|
|
1445
|
-
headerComment: "Copyright 2024 My Company",
|
|
1446
|
-
doc: moduleDoc,
|
|
1652
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1447
1653
|
get children() {
|
|
1448
|
-
return _$createComponent(py.
|
|
1449
|
-
|
|
1450
|
-
|
|
1654
|
+
return _$createComponent(py.SourceFile, {
|
|
1655
|
+
path: "test.py",
|
|
1656
|
+
headerComment: "Copyright 2024 My Company",
|
|
1657
|
+
doc: moduleDoc,
|
|
1658
|
+
get children() {
|
|
1659
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
1660
|
+
name: "hello",
|
|
1661
|
+
children: "pass"
|
|
1662
|
+
}, {
|
|
1663
|
+
fileName: import.meta.url,
|
|
1664
|
+
lineNumber: 757,
|
|
1665
|
+
columnNumber: 9
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1451
1668
|
}, {
|
|
1452
1669
|
fileName: import.meta.url,
|
|
1453
|
-
lineNumber:
|
|
1670
|
+
lineNumber: 752,
|
|
1454
1671
|
columnNumber: 7
|
|
1455
1672
|
});
|
|
1456
1673
|
}
|
|
1457
1674
|
}, {
|
|
1458
1675
|
fileName: import.meta.url,
|
|
1459
|
-
lineNumber:
|
|
1676
|
+
lineNumber: 751,
|
|
1460
1677
|
columnNumber: 5
|
|
1461
|
-
})
|
|
1462
|
-
|
|
1463
|
-
// headerComment and doc adjacent, then PEP 8 spacing before definition
|
|
1464
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1678
|
+
})).toRenderTo({
|
|
1679
|
+
"test.py": `
|
|
1465
1680
|
# Copyright 2024 My Company
|
|
1466
1681
|
"""
|
|
1467
1682
|
Module description.
|
|
@@ -1471,40 +1686,46 @@ it("headerComment + doc before definition", () => {
|
|
|
1471
1686
|
def hello():
|
|
1472
1687
|
pass
|
|
1473
1688
|
|
|
1474
|
-
|
|
1475
|
-
|
|
1689
|
+
`
|
|
1690
|
+
});
|
|
1476
1691
|
});
|
|
1477
1692
|
it("headerComment + futureImports before definition", () => {
|
|
1478
|
-
|
|
1479
|
-
path: "test.py",
|
|
1480
|
-
headerComment: "Copyright 2024 My Company",
|
|
1481
|
-
get futureImports() {
|
|
1482
|
-
return [_$createComponent(py.FutureStatement, {
|
|
1483
|
-
feature: "annotations"
|
|
1484
|
-
}, {
|
|
1485
|
-
fileName: import.meta.url,
|
|
1486
|
-
lineNumber: 746,
|
|
1487
|
-
columnNumber: 23
|
|
1488
|
-
})];
|
|
1489
|
-
},
|
|
1693
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1490
1694
|
get children() {
|
|
1491
|
-
return _$createComponent(py.
|
|
1492
|
-
|
|
1493
|
-
|
|
1695
|
+
return _$createComponent(py.SourceFile, {
|
|
1696
|
+
path: "test.py",
|
|
1697
|
+
headerComment: "Copyright 2024 My Company",
|
|
1698
|
+
get futureImports() {
|
|
1699
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1700
|
+
feature: "annotations"
|
|
1701
|
+
}, {
|
|
1702
|
+
fileName: import.meta.url,
|
|
1703
|
+
lineNumber: 781,
|
|
1704
|
+
columnNumber: 25
|
|
1705
|
+
})];
|
|
1706
|
+
},
|
|
1707
|
+
get children() {
|
|
1708
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
1709
|
+
name: "hello",
|
|
1710
|
+
children: "pass"
|
|
1711
|
+
}, {
|
|
1712
|
+
fileName: import.meta.url,
|
|
1713
|
+
lineNumber: 783,
|
|
1714
|
+
columnNumber: 9
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1494
1717
|
}, {
|
|
1495
1718
|
fileName: import.meta.url,
|
|
1496
|
-
lineNumber:
|
|
1719
|
+
lineNumber: 778,
|
|
1497
1720
|
columnNumber: 7
|
|
1498
1721
|
});
|
|
1499
1722
|
}
|
|
1500
1723
|
}, {
|
|
1501
1724
|
fileName: import.meta.url,
|
|
1502
|
-
lineNumber:
|
|
1725
|
+
lineNumber: 777,
|
|
1503
1726
|
columnNumber: 5
|
|
1504
|
-
})
|
|
1505
|
-
|
|
1506
|
-
// headerComment and futureImports adjacent, then PEP 8 spacing
|
|
1507
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1727
|
+
})).toRenderTo({
|
|
1728
|
+
"test.py": `
|
|
1508
1729
|
# Copyright 2024 My Company
|
|
1509
1730
|
|
|
1510
1731
|
from __future__ import annotations
|
|
@@ -1513,40 +1734,47 @@ it("headerComment + futureImports before definition", () => {
|
|
|
1513
1734
|
def hello():
|
|
1514
1735
|
pass
|
|
1515
1736
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1737
|
+
`
|
|
1738
|
+
});
|
|
1518
1739
|
});
|
|
1519
1740
|
it("headerComment + imports before definition", () => {
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
headerComment: "Copyright 2024 My Company",
|
|
1741
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1742
|
+
externals: [dataclassesModule],
|
|
1523
1743
|
get children() {
|
|
1524
|
-
return _$createComponent(py.
|
|
1525
|
-
|
|
1744
|
+
return _$createComponent(py.SourceFile, {
|
|
1745
|
+
path: "test.py",
|
|
1746
|
+
headerComment: "Copyright 2024 My Company",
|
|
1526
1747
|
get children() {
|
|
1527
|
-
return _$createComponent(py.
|
|
1528
|
-
name: "
|
|
1529
|
-
|
|
1748
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
1749
|
+
name: "User",
|
|
1750
|
+
get children() {
|
|
1751
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1752
|
+
name: "name",
|
|
1753
|
+
type: "str"
|
|
1754
|
+
}, {
|
|
1755
|
+
fileName: import.meta.url,
|
|
1756
|
+
lineNumber: 805,
|
|
1757
|
+
columnNumber: 11
|
|
1758
|
+
});
|
|
1759
|
+
}
|
|
1530
1760
|
}, {
|
|
1531
1761
|
fileName: import.meta.url,
|
|
1532
|
-
lineNumber:
|
|
1762
|
+
lineNumber: 804,
|
|
1533
1763
|
columnNumber: 9
|
|
1534
1764
|
});
|
|
1535
1765
|
}
|
|
1536
1766
|
}, {
|
|
1537
1767
|
fileName: import.meta.url,
|
|
1538
|
-
lineNumber:
|
|
1768
|
+
lineNumber: 803,
|
|
1539
1769
|
columnNumber: 7
|
|
1540
1770
|
});
|
|
1541
1771
|
}
|
|
1542
1772
|
}, {
|
|
1543
1773
|
fileName: import.meta.url,
|
|
1544
|
-
lineNumber:
|
|
1774
|
+
lineNumber: 802,
|
|
1545
1775
|
columnNumber: 5
|
|
1546
|
-
})
|
|
1547
|
-
|
|
1548
|
-
externals: [dataclassesModule]
|
|
1549
|
-
})).toRenderTo(d`
|
|
1776
|
+
})).toRenderTo({
|
|
1777
|
+
"test.py": `
|
|
1550
1778
|
# Copyright 2024 My Company
|
|
1551
1779
|
|
|
1552
1780
|
from dataclasses import dataclass
|
|
@@ -1556,8 +1784,8 @@ it("headerComment + imports before definition", () => {
|
|
|
1556
1784
|
class User:
|
|
1557
1785
|
name: str = None
|
|
1558
1786
|
|
|
1559
|
-
|
|
1560
|
-
|
|
1787
|
+
`
|
|
1788
|
+
});
|
|
1561
1789
|
});
|
|
1562
1790
|
it("headerComment + doc + futureImports before definition", () => {
|
|
1563
1791
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -1566,44 +1794,52 @@ it("headerComment + doc + futureImports before definition", () => {
|
|
|
1566
1794
|
children: "Module description."
|
|
1567
1795
|
}, {
|
|
1568
1796
|
fileName: import.meta.url,
|
|
1569
|
-
lineNumber:
|
|
1797
|
+
lineNumber: 826,
|
|
1570
1798
|
columnNumber: 33
|
|
1571
1799
|
})];
|
|
1572
1800
|
}
|
|
1573
1801
|
}, {
|
|
1574
1802
|
fileName: import.meta.url,
|
|
1575
|
-
lineNumber:
|
|
1803
|
+
lineNumber: 826,
|
|
1576
1804
|
columnNumber: 5
|
|
1577
1805
|
});
|
|
1578
|
-
|
|
1579
|
-
path: "test.py",
|
|
1580
|
-
headerComment: "Copyright 2024 My Company",
|
|
1581
|
-
doc: moduleDoc,
|
|
1582
|
-
get futureImports() {
|
|
1583
|
-
return [_$createComponent(py.FutureStatement, {
|
|
1584
|
-
feature: "annotations"
|
|
1585
|
-
}, {
|
|
1586
|
-
fileName: import.meta.url,
|
|
1587
|
-
lineNumber: 800,
|
|
1588
|
-
columnNumber: 23
|
|
1589
|
-
})];
|
|
1590
|
-
},
|
|
1806
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1591
1807
|
get children() {
|
|
1592
|
-
return _$createComponent(py.
|
|
1593
|
-
|
|
1594
|
-
|
|
1808
|
+
return _$createComponent(py.SourceFile, {
|
|
1809
|
+
path: "test.py",
|
|
1810
|
+
headerComment: "Copyright 2024 My Company",
|
|
1811
|
+
doc: moduleDoc,
|
|
1812
|
+
get futureImports() {
|
|
1813
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1814
|
+
feature: "annotations"
|
|
1815
|
+
}, {
|
|
1816
|
+
fileName: import.meta.url,
|
|
1817
|
+
lineNumber: 835,
|
|
1818
|
+
columnNumber: 25
|
|
1819
|
+
})];
|
|
1820
|
+
},
|
|
1821
|
+
get children() {
|
|
1822
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
1823
|
+
name: "hello",
|
|
1824
|
+
children: "pass"
|
|
1825
|
+
}, {
|
|
1826
|
+
fileName: import.meta.url,
|
|
1827
|
+
lineNumber: 837,
|
|
1828
|
+
columnNumber: 9
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1595
1831
|
}, {
|
|
1596
1832
|
fileName: import.meta.url,
|
|
1597
|
-
lineNumber:
|
|
1833
|
+
lineNumber: 831,
|
|
1598
1834
|
columnNumber: 7
|
|
1599
1835
|
});
|
|
1600
1836
|
}
|
|
1601
1837
|
}, {
|
|
1602
1838
|
fileName: import.meta.url,
|
|
1603
|
-
lineNumber:
|
|
1839
|
+
lineNumber: 830,
|
|
1604
1840
|
columnNumber: 5
|
|
1605
|
-
})
|
|
1606
|
-
|
|
1841
|
+
})).toRenderTo({
|
|
1842
|
+
"test.py": `
|
|
1607
1843
|
# Copyright 2024 My Company
|
|
1608
1844
|
"""
|
|
1609
1845
|
Module description.
|
|
@@ -1615,8 +1851,8 @@ it("headerComment + doc + futureImports before definition", () => {
|
|
|
1615
1851
|
def hello():
|
|
1616
1852
|
pass
|
|
1617
1853
|
|
|
1618
|
-
|
|
1619
|
-
|
|
1854
|
+
`
|
|
1855
|
+
});
|
|
1620
1856
|
});
|
|
1621
1857
|
it("headerComment + doc + futureImports + imports before definition", () => {
|
|
1622
1858
|
const moduleDoc = _$createComponent(py.ModuleDoc, {
|
|
@@ -1625,55 +1861,62 @@ it("headerComment + doc + futureImports + imports before definition", () => {
|
|
|
1625
1861
|
children: "Module description."
|
|
1626
1862
|
}, {
|
|
1627
1863
|
fileName: import.meta.url,
|
|
1628
|
-
lineNumber:
|
|
1864
|
+
lineNumber: 859,
|
|
1629
1865
|
columnNumber: 33
|
|
1630
1866
|
})];
|
|
1631
1867
|
}
|
|
1632
1868
|
}, {
|
|
1633
1869
|
fileName: import.meta.url,
|
|
1634
|
-
lineNumber:
|
|
1870
|
+
lineNumber: 859,
|
|
1635
1871
|
columnNumber: 5
|
|
1636
1872
|
});
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
headerComment: "Copyright 2024 My Company",
|
|
1640
|
-
doc: moduleDoc,
|
|
1641
|
-
get futureImports() {
|
|
1642
|
-
return [_$createComponent(py.FutureStatement, {
|
|
1643
|
-
feature: "annotations"
|
|
1644
|
-
}, {
|
|
1645
|
-
fileName: import.meta.url,
|
|
1646
|
-
lineNumber: 832,
|
|
1647
|
-
columnNumber: 23
|
|
1648
|
-
})];
|
|
1649
|
-
},
|
|
1873
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1874
|
+
externals: [dataclassesModule],
|
|
1650
1875
|
get children() {
|
|
1651
|
-
return _$createComponent(py.
|
|
1652
|
-
|
|
1876
|
+
return _$createComponent(py.SourceFile, {
|
|
1877
|
+
path: "test.py",
|
|
1878
|
+
headerComment: "Copyright 2024 My Company",
|
|
1879
|
+
doc: moduleDoc,
|
|
1880
|
+
get futureImports() {
|
|
1881
|
+
return [_$createComponent(py.FutureStatement, {
|
|
1882
|
+
feature: "annotations"
|
|
1883
|
+
}, {
|
|
1884
|
+
fileName: import.meta.url,
|
|
1885
|
+
lineNumber: 868,
|
|
1886
|
+
columnNumber: 25
|
|
1887
|
+
})];
|
|
1888
|
+
},
|
|
1653
1889
|
get children() {
|
|
1654
|
-
return _$createComponent(py.
|
|
1655
|
-
name: "
|
|
1656
|
-
|
|
1890
|
+
return _$createComponent(py.DataclassDeclaration, {
|
|
1891
|
+
name: "User",
|
|
1892
|
+
get children() {
|
|
1893
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
1894
|
+
name: "name",
|
|
1895
|
+
type: "str"
|
|
1896
|
+
}, {
|
|
1897
|
+
fileName: import.meta.url,
|
|
1898
|
+
lineNumber: 871,
|
|
1899
|
+
columnNumber: 11
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1657
1902
|
}, {
|
|
1658
1903
|
fileName: import.meta.url,
|
|
1659
|
-
lineNumber:
|
|
1904
|
+
lineNumber: 870,
|
|
1660
1905
|
columnNumber: 9
|
|
1661
1906
|
});
|
|
1662
1907
|
}
|
|
1663
1908
|
}, {
|
|
1664
1909
|
fileName: import.meta.url,
|
|
1665
|
-
lineNumber:
|
|
1910
|
+
lineNumber: 864,
|
|
1666
1911
|
columnNumber: 7
|
|
1667
1912
|
});
|
|
1668
1913
|
}
|
|
1669
1914
|
}, {
|
|
1670
1915
|
fileName: import.meta.url,
|
|
1671
|
-
lineNumber:
|
|
1916
|
+
lineNumber: 863,
|
|
1672
1917
|
columnNumber: 5
|
|
1673
|
-
})
|
|
1674
|
-
|
|
1675
|
-
externals: [dataclassesModule]
|
|
1676
|
-
})).toRenderTo(d`
|
|
1918
|
+
})).toRenderTo({
|
|
1919
|
+
"test.py": `
|
|
1677
1920
|
# Copyright 2024 My Company
|
|
1678
1921
|
"""
|
|
1679
1922
|
Module description.
|
|
@@ -1688,46 +1931,58 @@ it("headerComment + doc + futureImports + imports before definition", () => {
|
|
|
1688
1931
|
class User:
|
|
1689
1932
|
name: str = None
|
|
1690
1933
|
|
|
1691
|
-
|
|
1692
|
-
|
|
1934
|
+
`
|
|
1935
|
+
});
|
|
1693
1936
|
});
|
|
1694
1937
|
it("only headerComment in file (no children)", () => {
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1938
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1939
|
+
get children() {
|
|
1940
|
+
return _$createComponent(py.SourceFile, {
|
|
1941
|
+
path: "test.py",
|
|
1942
|
+
headerComment: "Copyright 2024 My Company"
|
|
1943
|
+
}, {
|
|
1944
|
+
fileName: import.meta.url,
|
|
1945
|
+
lineNumber: 898,
|
|
1946
|
+
columnNumber: 7
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1698
1949
|
}, {
|
|
1699
1950
|
fileName: import.meta.url,
|
|
1700
|
-
lineNumber:
|
|
1951
|
+
lineNumber: 897,
|
|
1701
1952
|
columnNumber: 5
|
|
1953
|
+
})).toRenderTo({
|
|
1954
|
+
"test.py": "# Copyright 2024 My Company"
|
|
1702
1955
|
});
|
|
1703
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1704
|
-
# Copyright 2024 My Company
|
|
1705
|
-
|
|
1706
|
-
`);
|
|
1707
1956
|
});
|
|
1708
1957
|
it("header + headerComment before definition", () => {
|
|
1709
|
-
|
|
1710
|
-
path: "test.py",
|
|
1711
|
-
header: "#!/usr/bin/env python3",
|
|
1712
|
-
headerComment: "Copyright 2024 My Company",
|
|
1958
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1713
1959
|
get children() {
|
|
1714
|
-
return _$createComponent(py.
|
|
1715
|
-
|
|
1716
|
-
|
|
1960
|
+
return _$createComponent(py.SourceFile, {
|
|
1961
|
+
path: "test.py",
|
|
1962
|
+
header: "#!/usr/bin/env python3",
|
|
1963
|
+
headerComment: "Copyright 2024 My Company",
|
|
1964
|
+
get children() {
|
|
1965
|
+
return _$createComponent(py.FunctionDeclaration, {
|
|
1966
|
+
name: "hello",
|
|
1967
|
+
children: "pass"
|
|
1968
|
+
}, {
|
|
1969
|
+
fileName: import.meta.url,
|
|
1970
|
+
lineNumber: 913,
|
|
1971
|
+
columnNumber: 9
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1717
1974
|
}, {
|
|
1718
1975
|
fileName: import.meta.url,
|
|
1719
|
-
lineNumber:
|
|
1976
|
+
lineNumber: 908,
|
|
1720
1977
|
columnNumber: 7
|
|
1721
1978
|
});
|
|
1722
1979
|
}
|
|
1723
1980
|
}, {
|
|
1724
1981
|
fileName: import.meta.url,
|
|
1725
|
-
lineNumber:
|
|
1982
|
+
lineNumber: 907,
|
|
1726
1983
|
columnNumber: 5
|
|
1727
|
-
})
|
|
1728
|
-
|
|
1729
|
-
// 2 blank lines before definition (PEP 8)
|
|
1730
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
1984
|
+
})).toRenderTo({
|
|
1985
|
+
"test.py": `
|
|
1731
1986
|
#!/usr/bin/env python3
|
|
1732
1987
|
# Copyright 2024 My Company
|
|
1733
1988
|
|
|
@@ -1735,32 +1990,38 @@ it("header + headerComment before definition", () => {
|
|
|
1735
1990
|
def hello():
|
|
1736
1991
|
pass
|
|
1737
1992
|
|
|
1738
|
-
|
|
1739
|
-
|
|
1993
|
+
`
|
|
1994
|
+
});
|
|
1740
1995
|
});
|
|
1741
1996
|
it("header + headerComment before class definition", () => {
|
|
1742
|
-
|
|
1743
|
-
path: "test.py",
|
|
1744
|
-
header: "#!/usr/bin/env python3",
|
|
1745
|
-
headerComment: "Copyright 2024 My Company",
|
|
1997
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1746
1998
|
get children() {
|
|
1747
|
-
return _$createComponent(py.
|
|
1748
|
-
|
|
1749
|
-
|
|
1999
|
+
return _$createComponent(py.SourceFile, {
|
|
2000
|
+
path: "test.py",
|
|
2001
|
+
header: "#!/usr/bin/env python3",
|
|
2002
|
+
headerComment: "Copyright 2024 My Company",
|
|
2003
|
+
get children() {
|
|
2004
|
+
return _$createComponent(py.ClassDeclaration, {
|
|
2005
|
+
name: "MyClass",
|
|
2006
|
+
children: "pass"
|
|
2007
|
+
}, {
|
|
2008
|
+
fileName: import.meta.url,
|
|
2009
|
+
lineNumber: 937,
|
|
2010
|
+
columnNumber: 9
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
1750
2013
|
}, {
|
|
1751
2014
|
fileName: import.meta.url,
|
|
1752
|
-
lineNumber:
|
|
2015
|
+
lineNumber: 932,
|
|
1753
2016
|
columnNumber: 7
|
|
1754
2017
|
});
|
|
1755
2018
|
}
|
|
1756
2019
|
}, {
|
|
1757
2020
|
fileName: import.meta.url,
|
|
1758
|
-
lineNumber:
|
|
2021
|
+
lineNumber: 931,
|
|
1759
2022
|
columnNumber: 5
|
|
1760
|
-
})
|
|
1761
|
-
|
|
1762
|
-
// 2 blank lines before definition (PEP 8)
|
|
1763
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
2023
|
+
})).toRenderTo({
|
|
2024
|
+
"test.py": `
|
|
1764
2025
|
#!/usr/bin/env python3
|
|
1765
2026
|
# Copyright 2024 My Company
|
|
1766
2027
|
|
|
@@ -1768,35 +2029,42 @@ it("header + headerComment before class definition", () => {
|
|
|
1768
2029
|
class MyClass:
|
|
1769
2030
|
pass
|
|
1770
2031
|
|
|
1771
|
-
|
|
1772
|
-
|
|
2032
|
+
`
|
|
2033
|
+
});
|
|
1773
2034
|
});
|
|
1774
2035
|
it("header + headerComment before non-definition", () => {
|
|
1775
|
-
|
|
1776
|
-
path: "test.py",
|
|
1777
|
-
header: "#!/usr/bin/env python3",
|
|
1778
|
-
headerComment: "Copyright 2024 My Company",
|
|
2036
|
+
expect(_$createComponent(TestOutputDirectory, {
|
|
1779
2037
|
get children() {
|
|
1780
|
-
return _$createComponent(py.
|
|
1781
|
-
|
|
1782
|
-
|
|
2038
|
+
return _$createComponent(py.SourceFile, {
|
|
2039
|
+
path: "test.py",
|
|
2040
|
+
header: "#!/usr/bin/env python3",
|
|
2041
|
+
headerComment: "Copyright 2024 My Company",
|
|
2042
|
+
get children() {
|
|
2043
|
+
return _$createComponent(py.VariableDeclaration, {
|
|
2044
|
+
name: "x",
|
|
2045
|
+
initializer: 42
|
|
2046
|
+
}, {
|
|
2047
|
+
fileName: import.meta.url,
|
|
2048
|
+
lineNumber: 961,
|
|
2049
|
+
columnNumber: 9
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
1783
2052
|
}, {
|
|
1784
2053
|
fileName: import.meta.url,
|
|
1785
|
-
lineNumber:
|
|
2054
|
+
lineNumber: 956,
|
|
1786
2055
|
columnNumber: 7
|
|
1787
2056
|
});
|
|
1788
2057
|
}
|
|
1789
2058
|
}, {
|
|
1790
2059
|
fileName: import.meta.url,
|
|
1791
|
-
lineNumber:
|
|
2060
|
+
lineNumber: 955,
|
|
1792
2061
|
columnNumber: 5
|
|
1793
|
-
})
|
|
1794
|
-
|
|
1795
|
-
// 1 blank line for non-definition
|
|
1796
|
-
expect(toSourceText(content)).toRenderTo(d`
|
|
2062
|
+
})).toRenderTo({
|
|
2063
|
+
"test.py": `
|
|
1797
2064
|
#!/usr/bin/env python3
|
|
1798
2065
|
# Copyright 2024 My Company
|
|
1799
2066
|
|
|
1800
|
-
x = 42`
|
|
2067
|
+
x = 42`
|
|
2068
|
+
});
|
|
1801
2069
|
});
|
|
1802
2070
|
//# sourceMappingURL=sourcefiles.test.js.map
|