@alloy-js/python 0.5.0-dev.1 → 0.5.0

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.
Files changed (217) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/dev/src/components/CallSignature.js +2 -2
  3. package/dist/dev/src/components/CallSignature.js.map +1 -1
  4. package/dist/dev/src/components/ConstructorDeclaration.js +1 -1
  5. package/dist/dev/src/components/ConstructorDeclaration.js.map +1 -1
  6. package/dist/dev/src/components/DataclassDeclaration.js +5 -5
  7. package/dist/dev/src/components/DataclassDeclaration.js.map +1 -1
  8. package/dist/dev/src/components/FunctionBase.js +9 -9
  9. package/dist/dev/src/components/FunctionBase.js.map +1 -1
  10. package/dist/dev/src/components/PropertyDeclaration.js +8 -8
  11. package/dist/dev/src/components/PropertyDeclaration.js.map +1 -1
  12. package/dist/dev/src/components/PyDoc.js +64 -64
  13. package/dist/dev/src/components/PyDoc.js.map +1 -1
  14. package/dist/dev/src/components/PydanticClassDeclaration.js +5 -5
  15. package/dist/dev/src/components/PydanticClassDeclaration.js.map +1 -1
  16. package/dist/dev/src/components/SourceFile.js +44 -32
  17. package/dist/dev/src/components/SourceFile.js.map +1 -1
  18. package/dist/dev/src/symbols/python-output-symbol.js.map +1 -1
  19. package/dist/dev/test/callsignatures.test.js +471 -297
  20. package/dist/dev/test/callsignatures.test.js.map +1 -1
  21. package/dist/dev/test/class-method-declaration.test.js +21 -10
  22. package/dist/dev/test/class-method-declaration.test.js.map +1 -1
  23. package/dist/dev/test/classdeclarations.test.js +459 -393
  24. package/dist/dev/test/classdeclarations.test.js.map +1 -1
  25. package/dist/dev/test/classinstantiations.test.js +201 -168
  26. package/dist/dev/test/classinstantiations.test.js.map +1 -1
  27. package/dist/dev/test/constructordeclaration.test.js +22 -11
  28. package/dist/dev/test/constructordeclaration.test.js.map +1 -1
  29. package/dist/dev/test/dataclassdeclarations.test.js +322 -368
  30. package/dist/dev/test/dataclassdeclarations.test.js.map +1 -1
  31. package/dist/dev/test/decoratorlist.test.js +96 -49
  32. package/dist/dev/test/decoratorlist.test.js.map +1 -1
  33. package/dist/dev/test/dundermethoddeclaration.test.js +22 -11
  34. package/dist/dev/test/dundermethoddeclaration.test.js.map +1 -1
  35. package/dist/dev/test/enums.test.js +218 -184
  36. package/dist/dev/test/enums.test.js.map +1 -1
  37. package/dist/dev/test/externals.test.js +57 -45
  38. package/dist/dev/test/externals.test.js.map +1 -1
  39. package/dist/dev/test/factories.test.js +124 -50
  40. package/dist/dev/test/factories.test.js.map +1 -1
  41. package/dist/dev/test/functioncallexpressions.test.js +199 -164
  42. package/dist/dev/test/functioncallexpressions.test.js.map +1 -1
  43. package/dist/dev/test/functiondeclaration.test.js +439 -272
  44. package/dist/dev/test/functiondeclaration.test.js.map +1 -1
  45. package/dist/dev/test/imports.test.js +273 -221
  46. package/dist/dev/test/imports.test.js.map +1 -1
  47. package/dist/dev/test/memberexpressions.test.js +1237 -972
  48. package/dist/dev/test/memberexpressions.test.js.map +1 -1
  49. package/dist/dev/test/methoddeclaration.test.js +142 -78
  50. package/dist/dev/test/methoddeclaration.test.js.map +1 -1
  51. package/dist/dev/test/namepolicies.test.js +130 -94
  52. package/dist/dev/test/namepolicies.test.js.map +1 -1
  53. package/dist/dev/test/propertydeclaration.test.js +88 -59
  54. package/dist/dev/test/propertydeclaration.test.js.map +1 -1
  55. package/dist/dev/test/pydanticclassdeclarations.test.js +299 -347
  56. package/dist/dev/test/pydanticclassdeclarations.test.js.map +1 -1
  57. package/dist/dev/test/pydocs.test.js +888 -715
  58. package/dist/dev/test/pydocs.test.js.map +1 -1
  59. package/dist/dev/test/references.test.js +42 -35
  60. package/dist/dev/test/references.test.js.map +1 -1
  61. package/dist/dev/test/sourcefiles.test.js +1109 -841
  62. package/dist/dev/test/sourcefiles.test.js.map +1 -1
  63. package/dist/dev/test/staticmethoddeclaration.test.js +21 -10
  64. package/dist/dev/test/staticmethoddeclaration.test.js.map +1 -1
  65. package/dist/dev/test/type-checking-imports.test.js +408 -359
  66. package/dist/dev/test/type-checking-imports.test.js.map +1 -1
  67. package/dist/dev/test/typereference.test.js +55 -40
  68. package/dist/dev/test/typereference.test.js.map +1 -1
  69. package/dist/dev/test/uniontypeexpression.test.js +222 -146
  70. package/dist/dev/test/uniontypeexpression.test.js.map +1 -1
  71. package/dist/dev/test/utils.js +39 -77
  72. package/dist/dev/test/utils.js.map +1 -1
  73. package/dist/dev/test/values.test.js +237 -101
  74. package/dist/dev/test/values.test.js.map +1 -1
  75. package/dist/dev/test/variables.test.js +321 -203
  76. package/dist/dev/test/variables.test.js.map +1 -1
  77. package/dist/dev/test/vitest.setup.js +2 -0
  78. package/dist/dev/test/vitest.setup.js.map +1 -0
  79. package/dist/src/components/CallSignature.d.ts.map +1 -1
  80. package/dist/src/components/CallSignature.js.map +1 -1
  81. package/dist/src/components/ConstructorDeclaration.d.ts.map +1 -1
  82. package/dist/src/components/ConstructorDeclaration.js.map +1 -1
  83. package/dist/src/components/DataclassDeclaration.d.ts.map +1 -1
  84. package/dist/src/components/DataclassDeclaration.js.map +1 -1
  85. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  86. package/dist/src/components/FunctionBase.js.map +1 -1
  87. package/dist/src/components/PropertyDeclaration.d.ts.map +1 -1
  88. package/dist/src/components/PropertyDeclaration.js.map +1 -1
  89. package/dist/src/components/PyDoc.d.ts.map +1 -1
  90. package/dist/src/components/PyDoc.js.map +1 -1
  91. package/dist/src/components/PydanticClassDeclaration.d.ts.map +1 -1
  92. package/dist/src/components/PydanticClassDeclaration.js.map +1 -1
  93. package/dist/src/components/SourceFile.d.ts +2 -2
  94. package/dist/src/components/SourceFile.d.ts.map +1 -1
  95. package/dist/src/components/SourceFile.js +12 -0
  96. package/dist/src/components/SourceFile.js.map +1 -1
  97. package/dist/src/symbols/python-output-symbol.d.ts.map +1 -1
  98. package/dist/src/symbols/python-output-symbol.js.map +1 -1
  99. package/dist/test/callsignatures.test.js +346 -272
  100. package/dist/test/callsignatures.test.js.map +1 -1
  101. package/dist/test/class-method-declaration.test.js +7 -4
  102. package/dist/test/class-method-declaration.test.js.map +1 -1
  103. package/dist/test/classdeclarations.test.js +302 -288
  104. package/dist/test/classdeclarations.test.js.map +1 -1
  105. package/dist/test/classinstantiations.test.js +112 -103
  106. package/dist/test/classinstantiations.test.js.map +1 -1
  107. package/dist/test/constructordeclaration.test.js +7 -4
  108. package/dist/test/constructordeclaration.test.js.map +1 -1
  109. package/dist/test/dataclassdeclarations.test.js +134 -184
  110. package/dist/test/dataclassdeclarations.test.js.map +1 -1
  111. package/dist/test/decoratorlist.test.js +59 -36
  112. package/dist/test/decoratorlist.test.js.map +1 -1
  113. package/dist/test/dundermethoddeclaration.test.js +7 -4
  114. package/dist/test/dundermethoddeclaration.test.js.map +1 -1
  115. package/dist/test/enums.test.js +161 -159
  116. package/dist/test/enums.test.js.map +1 -1
  117. package/dist/test/externals.test.js +24 -24
  118. package/dist/test/externals.test.js.map +1 -1
  119. package/dist/test/factories.test.js +75 -33
  120. package/dist/test/factories.test.js.map +1 -1
  121. package/dist/test/functioncallexpressions.test.js +117 -106
  122. package/dist/test/functioncallexpressions.test.js.map +1 -1
  123. package/dist/test/functiondeclaration.test.js +247 -180
  124. package/dist/test/functiondeclaration.test.js.map +1 -1
  125. package/dist/test/imports.test.js +171 -143
  126. package/dist/test/imports.test.js.map +1 -1
  127. package/dist/test/memberexpressions.test.js +582 -453
  128. package/dist/test/memberexpressions.test.js.map +1 -1
  129. package/dist/test/methoddeclaration.test.js +66 -46
  130. package/dist/test/methoddeclaration.test.js.map +1 -1
  131. package/dist/test/namepolicies.test.js +90 -78
  132. package/dist/test/namepolicies.test.js.map +1 -1
  133. package/dist/test/propertydeclaration.test.js +25 -20
  134. package/dist/test/propertydeclaration.test.js.map +1 -1
  135. package/dist/test/pydanticclassdeclarations.test.js +134 -190
  136. package/dist/test/pydanticclassdeclarations.test.js.map +1 -1
  137. package/dist/test/pydocs.test.js +573 -532
  138. package/dist/test/pydocs.test.js.map +1 -1
  139. package/dist/test/references.test.js +31 -28
  140. package/dist/test/references.test.js.map +1 -1
  141. package/dist/test/sourcefiles.test.js +700 -580
  142. package/dist/test/sourcefiles.test.js.map +1 -1
  143. package/dist/test/staticmethoddeclaration.test.js +7 -4
  144. package/dist/test/staticmethoddeclaration.test.js.map +1 -1
  145. package/dist/test/type-checking-imports.test.js +297 -284
  146. package/dist/test/type-checking-imports.test.js.map +1 -1
  147. package/dist/test/typereference.test.js +29 -22
  148. package/dist/test/typereference.test.js.map +1 -1
  149. package/dist/test/uniontypeexpression.test.js +124 -88
  150. package/dist/test/uniontypeexpression.test.js.map +1 -1
  151. package/dist/test/utils.d.ts +10 -17
  152. package/dist/test/utils.d.ts.map +1 -1
  153. package/dist/test/utils.js +32 -74
  154. package/dist/test/utils.js.map +1 -1
  155. package/dist/test/values.test.js +135 -67
  156. package/dist/test/values.test.js.map +1 -1
  157. package/dist/test/variables.test.js +201 -151
  158. package/dist/test/variables.test.js.map +1 -1
  159. package/dist/test/vitest.setup.d.ts +2 -0
  160. package/dist/test/vitest.setup.d.ts.map +1 -0
  161. package/dist/test/vitest.setup.js +2 -0
  162. package/dist/test/vitest.setup.js.map +1 -0
  163. package/dist/tsconfig.tsbuildinfo +1 -1
  164. package/docs/api/components/FunctionalEnumDeclaration.md +3 -6
  165. package/docs/api/components/MemberExpression.md +1 -5
  166. package/docs/api/components/SourceFile.md +20 -8
  167. package/docs/api/components/index.md +0 -2
  168. package/docs/api/functions/isTypeRefContext.md +1 -1
  169. package/docs/api/index.md +2 -2
  170. package/docs/api/types/ReferenceProps.md +7 -0
  171. package/docs/api/types/TypeRefContextProps.md +7 -0
  172. package/docs/api/types/index.md +2 -0
  173. package/package.json +11 -10
  174. package/src/components/CallSignature.tsx +4 -2
  175. package/src/components/ConstructorDeclaration.tsx +4 -2
  176. package/src/components/DataclassDeclaration.tsx +1 -2
  177. package/src/components/FunctionBase.tsx +1 -2
  178. package/src/components/PropertyDeclaration.tsx +8 -4
  179. package/src/components/PyDoc.tsx +12 -6
  180. package/src/components/PydanticClassDeclaration.tsx +1 -2
  181. package/src/components/SourceFile.tsx +6 -1
  182. package/src/symbols/python-output-symbol.ts +1 -2
  183. package/temp/api.json +107 -61
  184. package/test/callsignatures.test.tsx +309 -283
  185. package/test/class-method-declaration.test.tsx +3 -4
  186. package/test/classdeclarations.test.tsx +263 -248
  187. package/test/classinstantiations.test.tsx +115 -109
  188. package/test/constructordeclaration.test.tsx +9 -6
  189. package/test/dataclassdeclarations.test.tsx +243 -361
  190. package/test/decoratorlist.test.tsx +78 -59
  191. package/test/dundermethoddeclaration.test.tsx +3 -4
  192. package/test/enums.test.tsx +65 -81
  193. package/test/externals.test.tsx +25 -25
  194. package/test/factories.test.tsx +64 -22
  195. package/test/functioncallexpressions.test.tsx +123 -109
  196. package/test/functiondeclaration.test.tsx +209 -148
  197. package/test/imports.test.tsx +119 -91
  198. package/test/memberexpressions.test.tsx +265 -207
  199. package/test/methoddeclaration.test.tsx +84 -63
  200. package/test/namepolicies.test.tsx +69 -69
  201. package/test/propertydeclaration.test.tsx +7 -8
  202. package/test/pydanticclassdeclarations.test.tsx +355 -487
  203. package/test/pydocs.test.tsx +531 -579
  204. package/test/references.test.tsx +24 -23
  205. package/test/sourcefiles.test.tsx +527 -492
  206. package/test/staticmethoddeclaration.test.tsx +3 -4
  207. package/test/type-checking-imports.test.tsx +206 -218
  208. package/test/typereference.test.tsx +15 -12
  209. package/test/uniontypeexpression.test.tsx +74 -61
  210. package/test/utils.tsx +26 -110
  211. package/test/values.test.tsx +82 -32
  212. package/test/variables.test.tsx +162 -142
  213. package/test/vitest.setup.ts +1 -0
  214. package/tsdoc-metadata.json +1 -1
  215. package/vitest.config.ts +4 -0
  216. package/docs/api/components/Reference.md +0 -31
  217. package/docs/api/components/TypeRefContext.md +0 -41
@@ -1,46 +1,76 @@
1
+ import { render } from "@alloy-js/core";
1
2
  import { describe, expect, it } from "vitest";
2
3
  import * as py from "../src/index.js";
3
- import { toSourceText } from "./utils.js";
4
+ import { TestOutput } from "./utils.js";
4
5
 
5
6
  describe("Symbol factories", () => {
6
7
  it("createMethodSymbol throws outside class", () => {
7
8
  expect(() => {
8
- toSourceText([<py.MethodDeclaration name="m" />]);
9
+ render(
10
+ <TestOutput>
11
+ <py.MethodDeclaration name="m" />
12
+ </TestOutput>,
13
+ );
9
14
  }).toThrow('Method "m" must be declared inside a class (member scope)');
10
15
  });
11
16
 
12
17
  it("createMethodSymbol succeeds inside class", () => {
13
- const result = toSourceText([
14
- <py.ClassDeclaration name="C">
15
- <py.MethodDeclaration name="m" />
16
- </py.ClassDeclaration>,
17
- ]);
18
- expect(result).toContain("def m(self):");
18
+ expect(
19
+ <TestOutput>
20
+ <py.ClassDeclaration name="C">
21
+ <py.MethodDeclaration name="m" />
22
+ </py.ClassDeclaration>
23
+ </TestOutput>,
24
+ ).toRenderTo(
25
+ `
26
+ class C:
27
+ def m(self):
28
+ pass
29
+
30
+
31
+ `,
32
+ );
19
33
  });
20
34
 
21
35
  it("createFunctionSymbol usable in member scope (top-level function component still works nested)", () => {
22
- const result = toSourceText([
23
- <py.ClassDeclaration name="C">
24
- <py.StatementList>
25
- <py.FunctionDeclaration name="f" />
26
- </py.StatementList>
27
- </py.ClassDeclaration>,
28
- ]);
29
- // Nested free functions render without self/cls
30
- expect(result).toContain("def f():");
36
+ expect(
37
+ <TestOutput>
38
+ <py.ClassDeclaration name="C">
39
+ <py.StatementList>
40
+ <py.FunctionDeclaration name="f" />
41
+ </py.StatementList>
42
+ </py.ClassDeclaration>
43
+ </TestOutput>,
44
+ ).toRenderTo(
45
+ `
46
+ class C:
47
+ def f():
48
+ pass
49
+
50
+
51
+ `,
52
+ );
31
53
  });
32
54
  });
33
55
 
34
56
  describe("Validation Errors", () => {
35
57
  it("throws error when PropertyDeclaration is used outside of a class", () => {
36
58
  expect(() => {
37
- toSourceText([<py.PropertyDeclaration name="x" />]);
59
+ render(
60
+ <TestOutput>
61
+ <py.PropertyDeclaration name="x" />
62
+ </TestOutput>,
63
+ );
38
64
  }).toThrow('Method "x" must be declared inside a class (member scope)');
39
65
  });
40
66
 
41
67
  it("throws error when MethodDeclaration is used outside of a class", () => {
42
68
  expect(() => {
43
- toSourceText([<py.MethodDeclaration name="my_method" />]);
69
+ render(
70
+ <TestOutput>
71
+ <py.MethodDeclaration name="my_method" />
72
+ </TestOutput>,
73
+ );
44
74
  }).toThrow(
45
75
  'Method "my_method" must be declared inside a class (member scope)',
46
76
  );
@@ -48,7 +78,11 @@ describe("Validation Errors", () => {
48
78
 
49
79
  it("throws error when ClassMethodDeclaration is used outside of a class", () => {
50
80
  expect(() => {
51
- toSourceText([<py.ClassMethodDeclaration name="my_class_method" />]);
81
+ render(
82
+ <TestOutput>
83
+ <py.ClassMethodDeclaration name="my_class_method" />
84
+ </TestOutput>,
85
+ );
52
86
  }).toThrow(
53
87
  'Method "my_class_method" must be declared inside a class (member scope)',
54
88
  );
@@ -56,7 +90,11 @@ describe("Validation Errors", () => {
56
90
 
57
91
  it("throws error when StaticMethodDeclaration is used outside of a class", () => {
58
92
  expect(() => {
59
- toSourceText([<py.StaticMethodDeclaration name="my_static_method" />]);
93
+ render(
94
+ <TestOutput>
95
+ <py.StaticMethodDeclaration name="my_static_method" />
96
+ </TestOutput>,
97
+ );
60
98
  }).toThrow(
61
99
  'Method "my_static_method" must be declared inside a class (member scope)',
62
100
  );
@@ -64,7 +102,11 @@ describe("Validation Errors", () => {
64
102
 
65
103
  it("throws error when DunderMethodDeclaration is used outside of a class", () => {
66
104
  expect(() => {
67
- toSourceText([<py.DunderMethodDeclaration name="__init__" />]);
105
+ render(
106
+ <TestOutput>
107
+ <py.DunderMethodDeclaration name="__init__" />
108
+ </TestOutput>,
109
+ );
68
110
  }).toThrow(
69
111
  'Method "__init__" must be declared inside a class (member scope)',
70
112
  );
@@ -1,145 +1,159 @@
1
1
  import { refkey } from "@alloy-js/core";
2
- import { d } from "@alloy-js/core/testing";
3
2
  import { describe, expect, it } from "vitest";
4
3
  import * as py from "../src/index.js";
5
- import { toSourceText } from "./utils.jsx";
4
+ import { TestOutput } from "./utils.js";
6
5
 
7
6
  describe("FunctionCallExpression", () => {
8
7
  it("renders", () => {
9
- const result = toSourceText([<py.FunctionCallExpression target="foo" />]);
10
- expect(result).toRenderTo(d`
8
+ expect(
9
+ <TestOutput>
10
+ <py.FunctionCallExpression target="foo" />
11
+ </TestOutput>,
12
+ ).toRenderTo(
13
+ `
11
14
  foo()
12
- `);
15
+ `,
16
+ );
13
17
  });
18
+
14
19
  it("renders with args", () => {
15
- const result = toSourceText([
16
- <py.FunctionCallExpression target="foo" args={["a", "b"]} />,
17
- ]);
18
- expect(result).toRenderTo(d`
20
+ expect(
21
+ <TestOutput>
22
+ <py.FunctionCallExpression target="foo" args={["a", "b"]} />
23
+ </TestOutput>,
24
+ ).toRenderTo(
25
+ `
19
26
  foo(a, b)
20
- `);
27
+ `,
28
+ );
21
29
  });
22
30
 
23
31
  it("function call with variables", () => {
24
- // Creating the reference separately so the naming policy doesn't interfere
25
32
  const methodRef = refkey();
26
- const result = toSourceText([
27
- <py.StatementList>
28
- <py.FunctionDeclaration name="runFunc" refkey={methodRef} />
29
- <py.FunctionCallExpression
30
- target={methodRef}
31
- args={[
32
- <py.Atom jsValue={"A name"} />,
33
- <py.Atom jsValue={42} />,
34
- <py.Atom jsValue={true} />,
35
- ]}
36
- />
37
- </py.StatementList>,
38
- ]);
39
- const expected = d`
33
+ expect(
34
+ <TestOutput>
35
+ <py.StatementList>
36
+ <py.FunctionDeclaration name="runFunc" refkey={methodRef} />
37
+ <py.FunctionCallExpression
38
+ target={methodRef}
39
+ args={[
40
+ <py.Atom jsValue={"A name"} />,
41
+ <py.Atom jsValue={42} />,
42
+ <py.Atom jsValue={true} />,
43
+ ]}
44
+ />
45
+ </py.StatementList>
46
+ </TestOutput>,
47
+ ).toRenderTo(
48
+ `
40
49
  def run_func():
41
50
  pass
42
51
 
43
52
  run_func("A name", 42, True)
44
- `;
45
- expect(result).toRenderTo(expected);
53
+ `,
54
+ );
46
55
  });
47
56
 
48
57
  it("function call with variables and assignment", () => {
49
- // Creating the reference separately so the naming policy doesn't interfere
50
58
  const methodRef = refkey();
51
- const result = toSourceText([
52
- <py.StatementList>
53
- <py.FunctionDeclaration
54
- name="runFunc"
55
- returnType="str"
56
- refkey={methodRef}
57
- parameters={[
58
- { name: "name", type: "str" },
59
- { name: "number", type: "int" },
60
- { name: "flag", type: "bool" },
61
- ]}
62
- />
63
- <py.VariableDeclaration
64
- name="result"
65
- type="str"
66
- initializer={
67
- <py.FunctionCallExpression
68
- target={methodRef}
69
- args={[
70
- <py.Atom jsValue={"A name"} />,
71
- <py.Atom jsValue={42} />,
72
- <py.Atom jsValue={true} />,
73
- ]}
74
- />
75
- }
76
- />
77
- </py.StatementList>,
78
- ]);
79
- const expected = d`
59
+ expect(
60
+ <TestOutput>
61
+ <py.StatementList>
62
+ <py.FunctionDeclaration
63
+ name="runFunc"
64
+ returnType="str"
65
+ refkey={methodRef}
66
+ parameters={[
67
+ { name: "name", type: "str" },
68
+ { name: "number", type: "int" },
69
+ { name: "flag", type: "bool" },
70
+ ]}
71
+ />
72
+ <py.VariableDeclaration
73
+ name="result"
74
+ type="str"
75
+ initializer={
76
+ <py.FunctionCallExpression
77
+ target={methodRef}
78
+ args={[
79
+ <py.Atom jsValue={"A name"} />,
80
+ <py.Atom jsValue={42} />,
81
+ <py.Atom jsValue={true} />,
82
+ ]}
83
+ />
84
+ }
85
+ />
86
+ </py.StatementList>
87
+ </TestOutput>,
88
+ ).toRenderTo(
89
+ `
80
90
  def run_func(name: str, number: int, flag: bool) -> str:
81
91
  pass
82
92
 
83
93
  result: str = run_func("A name", 42, True)
84
- `;
85
- expect(result).toRenderTo(expected);
94
+ `,
95
+ );
86
96
  });
87
97
 
88
98
  it("Method call without a reference and with call statement vars", () => {
89
- const result = toSourceText([
90
- <py.StatementList>
91
- <py.FunctionCallExpression
92
- target={"example_method"}
93
- args={[
94
- <py.VariableDeclaration
95
- name="name"
96
- initializer={"A name"}
97
- callStatementVar
98
- />,
99
- <py.VariableDeclaration
100
- name="number"
101
- initializer={42}
102
- callStatementVar
103
- />,
104
- <py.VariableDeclaration
105
- name="flag"
106
- initializer={true}
107
- callStatementVar
108
- />,
109
- ]}
110
- />
111
- </py.StatementList>,
112
- ]);
113
- const expected = d`
99
+ expect(
100
+ <TestOutput>
101
+ <py.StatementList>
102
+ <py.FunctionCallExpression
103
+ target={"example_method"}
104
+ args={[
105
+ <py.VariableDeclaration
106
+ name="name"
107
+ initializer={"A name"}
108
+ callStatementVar
109
+ />,
110
+ <py.VariableDeclaration
111
+ name="number"
112
+ initializer={42}
113
+ callStatementVar
114
+ />,
115
+ <py.VariableDeclaration
116
+ name="flag"
117
+ initializer={true}
118
+ callStatementVar
119
+ />,
120
+ ]}
121
+ />
122
+ </py.StatementList>
123
+ </TestOutput>,
124
+ ).toRenderTo(
125
+ `
114
126
  example_method(name="A name", number=42, flag=True)
115
- `;
116
- expect(result).toRenderTo(expected);
127
+ `,
128
+ );
117
129
  });
118
130
 
119
131
  it("Method call without a reference mixing unnamed and named vars", () => {
120
- const result = toSourceText([
121
- <py.StatementList>
122
- <py.FunctionCallExpression
123
- target={"example_method"}
124
- args={[
125
- <py.Atom jsValue={"A name"} />,
126
- <py.VariableDeclaration
127
- name="number"
128
- initializer={42}
129
- callStatementVar
130
- />,
131
- <py.VariableDeclaration
132
- name="flag"
133
- initializer={true}
134
- callStatementVar
135
- />,
136
- ]}
137
- />
138
- </py.StatementList>,
139
- ]);
140
- const expected = d`
132
+ expect(
133
+ <TestOutput>
134
+ <py.StatementList>
135
+ <py.FunctionCallExpression
136
+ target={"example_method"}
137
+ args={[
138
+ <py.Atom jsValue={"A name"} />,
139
+ <py.VariableDeclaration
140
+ name="number"
141
+ initializer={42}
142
+ callStatementVar
143
+ />,
144
+ <py.VariableDeclaration
145
+ name="flag"
146
+ initializer={true}
147
+ callStatementVar
148
+ />,
149
+ ]}
150
+ />
151
+ </py.StatementList>
152
+ </TestOutput>,
153
+ ).toRenderTo(
154
+ `
141
155
  example_method("A name", number=42, flag=True)
142
- `;
143
- expect(result).toRenderTo(expected);
156
+ `,
157
+ );
144
158
  });
145
159
  });