@@ -75,8 +75,8 @@ fn stdin_filename() {
75
75
"### ) ;
76
76
}
77
77
78
- #[ test]
79
78
/// Raise `TCH` errors in `.py` files ...
79
+ #[ test]
80
80
fn stdin_source_type_py ( ) {
81
81
assert_cmd_snapshot ! ( Command :: new( get_cargo_bin( BIN_NAME ) )
82
82
. args( STDIN_BASE_OPTIONS )
@@ -136,7 +136,7 @@ fn stdin_json() {
136
136
}
137
137
138
138
#[ test]
139
- fn stdin_fix ( ) {
139
+ fn stdin_fix_py ( ) {
140
140
let args = [ "--fix" ] ;
141
141
assert_cmd_snapshot ! ( Command :: new( get_cargo_bin( BIN_NAME ) )
142
142
. args( STDIN_BASE_OPTIONS )
@@ -153,6 +153,173 @@ fn stdin_fix() {
153
153
"### ) ;
154
154
}
155
155
156
+ #[ test]
157
+ fn stdin_fix_jupyter ( ) {
158
+ let args = [ "--fix" , "--stdin-filename" , "Jupyter.ipynb" ] ;
159
+ assert_cmd_snapshot ! ( Command :: new( get_cargo_bin( BIN_NAME ) )
160
+ . args( STDIN_BASE_OPTIONS )
161
+ . args( args)
162
+ . pass_stdin( r#"{
163
+ "cells": [
164
+ {
165
+ "cell_type": "code",
166
+ "execution_count": 1,
167
+ "id": "dccc687c-96e2-4604-b957-a8a89b5bec06",
168
+ "metadata": {},
169
+ "outputs": [],
170
+ "source": [
171
+ "import os"
172
+ ]
173
+ },
174
+ {
175
+ "cell_type": "markdown",
176
+ "id": "19e1b029-f516-4662-a9b9-623b93edac1a",
177
+ "metadata": {},
178
+ "source": [
179
+ "Foo"
180
+ ]
181
+ },
182
+ {
183
+ "cell_type": "code",
184
+ "execution_count": 2,
185
+ "id": "cdce7b92-b0fb-4c02-86f6-e233b26fa84f",
186
+ "metadata": {},
187
+ "outputs": [],
188
+ "source": [
189
+ "import sys"
190
+ ]
191
+ },
192
+ {
193
+ "cell_type": "code",
194
+ "execution_count": 3,
195
+ "id": "e40b33d2-7fe4-46c5-bdf0-8802f3052565",
196
+ "metadata": {},
197
+ "outputs": [
198
+ {
199
+ "name": "stdout",
200
+ "output_type": "stream",
201
+ "text": [
202
+ "1\n"
203
+ ]
204
+ }
205
+ ],
206
+ "source": [
207
+ "print(1)"
208
+ ]
209
+ },
210
+ {
211
+ "cell_type": "code",
212
+ "execution_count": null,
213
+ "id": "a1899bc8-d46f-4ec0-b1d1-e1ca0f04bf60",
214
+ "metadata": {},
215
+ "outputs": [],
216
+ "source": []
217
+ }
218
+ ],
219
+ "metadata": {
220
+ "kernelspec": {
221
+ "display_name": "Python 3 (ipykernel)",
222
+ "language": "python",
223
+ "name": "python3"
224
+ },
225
+ "language_info": {
226
+ "codemirror_mode": {
227
+ "name": "ipython",
228
+ "version": 3
229
+ },
230
+ "file_extension": ".py",
231
+ "mimetype": "text/x-python",
232
+ "name": "python",
233
+ "nbconvert_exporter": "python",
234
+ "pygments_lexer": "ipython3",
235
+ "version": "3.11.2"
236
+ }
237
+ },
238
+ "nbformat": 4,
239
+ "nbformat_minor": 5
240
+ }"# ) , @r###"
241
+ success: true
242
+ exit_code: 0
243
+ ----- stdout -----
244
+ {
245
+ "cells": [
246
+ {
247
+ "cell_type": "code",
248
+ "execution_count": 1,
249
+ "id": "dccc687c-96e2-4604-b957-a8a89b5bec06",
250
+ "metadata": {},
251
+ "outputs": [],
252
+ "source": []
253
+ },
254
+ {
255
+ "cell_type": "markdown",
256
+ "id": "19e1b029-f516-4662-a9b9-623b93edac1a",
257
+ "metadata": {},
258
+ "source": [
259
+ "Foo"
260
+ ]
261
+ },
262
+ {
263
+ "cell_type": "code",
264
+ "execution_count": 2,
265
+ "id": "cdce7b92-b0fb-4c02-86f6-e233b26fa84f",
266
+ "metadata": {},
267
+ "outputs": [],
268
+ "source": []
269
+ },
270
+ {
271
+ "cell_type": "code",
272
+ "execution_count": 3,
273
+ "id": "e40b33d2-7fe4-46c5-bdf0-8802f3052565",
274
+ "metadata": {},
275
+ "outputs": [
276
+ {
277
+ "name": "stdout",
278
+ "output_type": "stream",
279
+ "text": [
280
+ "1\n"
281
+ ]
282
+ }
283
+ ],
284
+ "source": [
285
+ "print(1)"
286
+ ]
287
+ },
288
+ {
289
+ "cell_type": "code",
290
+ "execution_count": null,
291
+ "id": "a1899bc8-d46f-4ec0-b1d1-e1ca0f04bf60",
292
+ "metadata": {},
293
+ "outputs": [],
294
+ "source": []
295
+ }
296
+ ],
297
+ "metadata": {
298
+ "kernelspec": {
299
+ "display_name": "Python 3 (ipykernel)",
300
+ "language": "python",
301
+ "name": "python3"
302
+ },
303
+ "language_info": {
304
+ "codemirror_mode": {
305
+ "name": "ipython",
306
+ "version": 3
307
+ },
308
+ "file_extension": ".py",
309
+ "mimetype": "text/x-python",
310
+ "name": "python",
311
+ "nbconvert_exporter": "python",
312
+ "pygments_lexer": "ipython3",
313
+ "version": "3.11.2"
314
+ }
315
+ },
316
+ "nbformat": 4,
317
+ "nbformat_minor": 5
318
+ }
319
+ ----- stderr -----
320
+ "### ) ;
321
+ }
322
+
156
323
#[ test]
157
324
fn stdin_fix_when_not_fixable_should_still_print_contents ( ) {
158
325
let args = [ "--fix" ] ;
0 commit comments