@@ -280,3 +280,114 @@ fn python_list_unsupported_version() {
280280 error: Invalid version request: Python <3.13 does not support free-threading but 3.12t was requested.
281281 " ) ;
282282}
283+
284+ #[ test]
285+ fn python_list_downloads ( ) {
286+ let context: TestContext = TestContext :: new_with_versions ( & [ ] ) . with_filtered_python_keys ( ) ;
287+
288+ // We do not test showing all interpreters — as it differs per platform
289+ // Instead, we choose a Python version where our available distributions are stable
290+
291+ // Test the default display, which requires reverting the test context disabling Python downloads
292+ uv_snapshot ! ( context. filters( ) , context. python_list( ) . arg( "3.10" ) . env_remove( "UV_PYTHON_DOWNLOADS" ) , @r"
293+ success: true
294+ exit_code: 0
295+ ----- stdout -----
296+ cpython-3.10.16-[PLATFORM] <download available>
297+
298+ ----- stderr -----
299+ " ) ;
300+
301+ // Show patch versions
302+ uv_snapshot ! ( context. filters( ) , context. python_list( ) . arg( "3.10" ) . arg( "--all-versions" ) . env_remove( "UV_PYTHON_DOWNLOADS" ) , @r"
303+ success: true
304+ exit_code: 0
305+ ----- stdout -----
306+ cpython-3.10.16-[PLATFORM] <download available>
307+ cpython-3.10.15-[PLATFORM] <download available>
308+ cpython-3.10.14-[PLATFORM] <download available>
309+ cpython-3.10.13-[PLATFORM] <download available>
310+ cpython-3.10.12-[PLATFORM] <download available>
311+ cpython-3.10.11-[PLATFORM] <download available>
312+ cpython-3.10.9-[PLATFORM] <download available>
313+ cpython-3.10.8-[PLATFORM] <download available>
314+ cpython-3.10.7-[PLATFORM] <download available>
315+ cpython-3.10.6-[PLATFORM] <download available>
316+ cpython-3.10.5-[PLATFORM] <download available>
317+ cpython-3.10.4-[PLATFORM] <download available>
318+ cpython-3.10.3-[PLATFORM] <download available>
319+ cpython-3.10.2-[PLATFORM] <download available>
320+ cpython-3.10.0-[PLATFORM] <download available>
321+
322+ ----- stderr -----
323+ " ) ;
324+ }
325+
326+ #[ test]
327+ #[ cfg( feature = "python-managed" ) ]
328+ fn python_list_downloads_installed ( ) {
329+ use assert_cmd:: assert:: OutputAssertExt ;
330+
331+ let context: TestContext = TestContext :: new_with_versions ( & [ ] )
332+ . with_filtered_python_keys ( )
333+ . with_filtered_python_names ( )
334+ . with_filtered_virtualenv_bin ( )
335+ . with_managed_python_dirs ( ) ;
336+
337+ // We do not test showing all interpreters — as it differs per platform
338+ // Instead, we choose a Python version where our available distributions are stable
339+
340+ // First, the download is shown as available
341+ uv_snapshot ! ( context. filters( ) , context. python_list( ) . arg( "3.10" ) . env_remove( "UV_PYTHON_DOWNLOADS" ) , @r"
342+ success: true
343+ exit_code: 0
344+ ----- stdout -----
345+ cpython-3.10.16-[PLATFORM] <download available>
346+
347+ ----- stderr -----
348+ " ) ;
349+
350+ // TODO(zanieb): It'd be nice to test `--show-urls` here too but we need special filtering for
351+ // the URL
352+
353+ // But not if `--only-installed` is used
354+ uv_snapshot ! ( context. filters( ) , context. python_list( ) . arg( "3.10" ) . arg( "--only-installed" ) . env_remove( "UV_PYTHON_DOWNLOADS" ) , @r"
355+ success: true
356+ exit_code: 0
357+ ----- stdout -----
358+
359+ ----- stderr -----
360+ " ) ;
361+
362+ // Install a Python version
363+ context. python_install ( ) . arg ( "3.10" ) . assert ( ) . success ( ) ;
364+
365+ // Then, it should be listed as installed instead of available
366+ uv_snapshot ! ( context. filters( ) , context. python_list( ) . arg( "3.10" ) . env_remove( "UV_PYTHON_DOWNLOADS" ) , @r"
367+ success: true
368+ exit_code: 0
369+ ----- stdout -----
370+ cpython-3.10.16-[PLATFORM] managed/cpython-3.10.16-[PLATFORM]/[BIN]/python
371+
372+ ----- stderr -----
373+ " ) ;
374+
375+ // But, the display should be reverted if `--only-downloads` is used
376+ uv_snapshot ! ( context. filters( ) , context. python_list( ) . arg( "3.10" ) . arg( "--only-downloads" ) . env_remove( "UV_PYTHON_DOWNLOADS" ) , @r"
377+ success: true
378+ exit_code: 0
379+ ----- stdout -----
380+ cpython-3.10.16-[PLATFORM] <download available>
381+
382+ ----- stderr -----
383+ " ) ;
384+
385+ // And should not be shown if `--no-managed-python` is used
386+ uv_snapshot ! ( context. filters( ) , context. python_list( ) . arg( "3.10" ) . arg( "--no-managed-python" ) . env_remove( "UV_PYTHON_DOWNLOADS" ) , @r"
387+ success: true
388+ exit_code: 0
389+ ----- stdout -----
390+
391+ ----- stderr -----
392+ " ) ;
393+ }
0 commit comments