diff --git a/pixi.lock b/pixi.lock index c16c5c805b..9bdeb4cbb5 100644 --- a/pixi.lock +++ b/pixi.lock @@ -136,7 +136,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/schema-0.7.7-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/sysroot_linux-64-2.17-h0157908_18.conda - conda: https://prefix.dev/conda-forge/noarch/tabulate-0.9.0-pyhd8ed1ab_2.conda - conda: https://prefix.dev/conda-forge/linux-64/tbb-2022.1.0-h4ce085d_0.conda @@ -278,7 +277,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/schema-0.7.7-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/sysroot_linux-aarch64-2.17-h68829e0_18.conda - conda: https://prefix.dev/conda-forge/noarch/tabulate-0.9.0-pyhd8ed1ab_2.conda - conda: https://prefix.dev/conda-forge/noarch/tbump-6.9.0-pyhd8ed1ab_0.tar.bz2 @@ -425,7 +423,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda - conda: https://prefix.dev/conda-forge/osx-64/sigtool-0.1.3-h88f4db0_0.tar.bz2 - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/tabulate-0.9.0-pyhd8ed1ab_2.conda - conda: https://prefix.dev/conda-forge/osx-64/tapi-1300.6.5-h390ca13_0.conda - conda: https://prefix.dev/conda-forge/noarch/tbump-6.9.0-pyhd8ed1ab_0.tar.bz2 @@ -574,7 +571,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/sigtool-0.1.3-h44b9a77_0.tar.bz2 - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/tabulate-0.9.0-pyhd8ed1ab_2.conda - conda: https://prefix.dev/conda-forge/osx-arm64/tapi-1300.6.5-h03f4b80_0.conda - conda: https://prefix.dev/conda-forge/noarch/tbump-6.9.0-pyhd8ed1ab_0.tar.bz2 @@ -692,7 +688,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/schema-0.7.7-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/tabulate-0.9.0-pyhd8ed1ab_2.conda - conda: https://prefix.dev/conda-forge/noarch/tbump-6.9.0-pyhd8ed1ab_0.tar.bz2 - conda: https://prefix.dev/conda-forge/win-64/tk-8.6.13-h2c6b04d_2.conda @@ -1458,7 +1453,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/rust-src-1.86.0-unix_0.conda - conda: https://prefix.dev/conda-forge/noarch/rust-std-x86_64-unknown-linux-gnu-1.86.0-h2c6d0dc_0.conda - conda: https://prefix.dev/conda-forge/linux-64/shellcheck-0.10.0-ha770c72_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/sysroot_linux-64-2.17-h0157908_18.conda - conda: https://prefix.dev/conda-forge/linux-64/taplo-0.10.0-h2d22210_1.conda - conda: https://prefix.dev/conda-forge/linux-64/tbb-2022.1.0-h4ce085d_0.conda @@ -1567,7 +1561,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/rust-src-1.86.0-unix_0.conda - conda: https://prefix.dev/conda-forge/noarch/rust-std-aarch64-unknown-linux-gnu-1.86.0-hbe8e118_0.conda - conda: https://prefix.dev/conda-forge/linux-aarch64/shellcheck-0.10.0-h8af1aa0_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/noarch/sysroot_linux-aarch64-2.17-h68829e0_18.conda - conda: https://prefix.dev/conda-forge/linux-aarch64/taplo-0.10.0-h3618846_1.conda - conda: https://prefix.dev/conda-forge/linux-aarch64/tk-8.6.13-noxft_h5688188_102.conda @@ -1681,7 +1674,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/rust-std-x86_64-apple-darwin-1.86.0-h38e4360_0.conda - conda: https://prefix.dev/conda-forge/osx-64/shellcheck-0.10.0-h7dd6a17_0.conda - conda: https://prefix.dev/conda-forge/osx-64/sigtool-0.1.3-h88f4db0_0.tar.bz2 - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/osx-64/tapi-1300.6.5-h390ca13_0.conda - conda: https://prefix.dev/conda-forge/osx-64/taplo-0.10.0-hffa81eb_1.conda - conda: https://prefix.dev/conda-forge/osx-64/tk-8.6.13-hf689a15_2.conda @@ -1797,7 +1789,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/rust-std-aarch64-apple-darwin-1.86.0-hf6ec828_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/shellcheck-0.10.0-hecfb573_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/sigtool-0.1.3-h44b9a77_0.tar.bz2 - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/tapi-1300.6.5-h03f4b80_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/taplo-0.10.0-h2b2570c_1.conda - conda: https://prefix.dev/conda-forge/osx-arm64/tk-8.6.13-h892fb3f_2.conda @@ -1882,7 +1873,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/rust-src-1.86.0-win_0.conda - conda: https://prefix.dev/conda-forge/noarch/rust-std-x86_64-pc-windows-msvc-1.86.0-h17fc481_0.conda - conda: https://prefix.dev/conda-forge/win-64/shellcheck-0.10.0-h57928b3_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/win-64/taplo-0.10.0-h63977a8_1.conda - conda: https://prefix.dev/conda-forge/win-64/tk-8.6.13-h2c6b04d_2.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-2.2.1-pyhd8ed1ab_1.conda @@ -2214,7 +2204,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/rich-14.0.0-pyh29332c3_0.conda - conda: https://prefix.dev/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-64/tk-8.6.13-noxft_hd72426e_102.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-2.2.1-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda @@ -2283,7 +2272,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/rich-14.0.0-pyh29332c3_0.conda - conda: https://prefix.dev/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/linux-aarch64/tk-8.6.13-noxft_h5688188_102.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-2.2.1-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda @@ -2346,7 +2334,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/rich-14.0.0-pyh29332c3_0.conda - conda: https://prefix.dev/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/osx-64/tk-8.6.13-hf689a15_2.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-2.2.1-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda @@ -2409,7 +2396,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/rich-14.0.0-pyh29332c3_0.conda - conda: https://prefix.dev/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/osx-arm64/tk-8.6.13-h892fb3f_2.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-2.2.1-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda @@ -2470,7 +2456,6 @@ environments: - conda: https://prefix.dev/conda-forge/noarch/rich-14.0.0-pyh29332c3_0.conda - conda: https://prefix.dev/conda-forge/noarch/setuptools-80.9.0-pyhff2d567_0.conda - conda: https://prefix.dev/conda-forge/noarch/six-1.17.0-pyhd8ed1ab_0.conda - - conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - conda: https://prefix.dev/conda-forge/win-64/tk-8.6.13-h2c6b04d_2.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-2.2.1-pyhd8ed1ab_1.conda - conda: https://prefix.dev/conda-forge/noarch/tomli-w-1.2.0-pyhd8ed1ab_0.conda @@ -9701,16 +9686,6 @@ packages: license_family: MIT size: 16385 timestamp: 1733381032766 -- conda: https://prefix.dev/conda-forge/noarch/syrupy-4.9.1-pyhd8ed1ab_0.conda - sha256: 62f549992509c3d1a0ecedd7a4784972c2542f23ec1c49ada92027c156cd31a5 - md5: f8e0fc78b3292b215266c19cdddaa6ab - depends: - - pytest >=7.0.0,<9.0.0 - - python >=3.9,<4.0 - license: Apache-2.0 - license_family: APACHE - size: 47524 - timestamp: 1742814070006 - conda: https://prefix.dev/conda-forge/noarch/sysroot_linux-64-2.17-h0157908_18.conda sha256: 69ab5804bdd2e8e493d5709eebff382a72fab3e9af6adf93a237ccf8f7dbd624 md5: 460eba7851277ec1fd80a1a24080787a diff --git a/pixi.toml b/pixi.toml index ff9e487d02..73cd408a6a 100644 --- a/pixi.toml +++ b/pixi.toml @@ -53,7 +53,6 @@ pytest-timeout = ">=2.3.1,<3" pytest-xdist = ">=3.6.1,<4" pyyaml = ">=6.0.2,<7" rich = ">=14,<15" -syrupy = ">=4.8.0,<5" tomli-w = ">=1.0,<2" types-pyyaml = ">=6.0.12.20241230,<7" @@ -96,7 +95,6 @@ tbump = ">=6.9.0,<6.10" [feature.dev.tasks] insta-review = "cargo insta review --workspace" -syrupy-update = "pytest --snapshot-update" update-rattler = "cargo upgrade -p rattler -p file_url -p rattler_cache -p rattler_conda_types -p rattler_digest -p rattler_lock -p rattler_networking -p rattler_repodata_gateway -p rattler_shell -p rattler_solve -p rattler_virtual_packages" # UV dependency management @@ -117,6 +115,10 @@ description = "Switch to local rattler development dependencies" cmd = "python scripts/local_patch.py rattler remote" description = "Switch back to remote rattler dependencies" +[feature.dev.tasks.snapshot-update] +args = [{ "arg" = "expression", "default" = "" }] +cmd = "pytest --inline-snapshot=fix -k '{{ expression }}'" + [feature.lint.dependencies] actionlint = ">=1.7.7,<2" dprint = ">=0.49.1,<0.51" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..3f305d4c6c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,5 @@ +# there is no Python project, +# this file is just for configuring tools used in Python tests + +[tool.inline-snapshot] +format-command = "pixi run -e lint ruff format --stdin-filename {filename}" diff --git a/tests/integration_python/__snapshots__/test_docs_examples.ambr b/tests/integration_python/__snapshots__/test_docs_examples.ambr deleted file mode 100644 index a25c5fc9e8..0000000000 --- a/tests/integration_python/__snapshots__/test_docs_examples.ambr +++ /dev/null @@ -1,86 +0,0 @@ -# serializer version: 1 -# name: test_doc_pixi_workspaces_minijinja_task_args - dict({ - 'task1': ''' - HOI RUBEN - - ''', - 'task2': ''' - hoi ruben - - ''', - 'task3': ''' - hoi Ruben! - - ''', - 'task4': ''' - unix - - ''', - 'task5': ''' - hoi - Ruben - - ''', - }) -# --- -# name: test_doc_pixi_workspaces_pixi_build[advanced_cpp] - ''' - 3 - - ''' -# --- -# name: test_doc_pixi_workspaces_pixi_build[cpp] - ''' - 3 - - ''' -# --- -# name: test_doc_pixi_workspaces_pixi_build[getting_started] - ''' - ┏━━━━━━━━━━━━━━┳━━━━━┳━━━━━━━━━━━━━┓ - ┃ name ┃ age ┃ city ┃ - ┡━━━━━━━━━━━━━━╇━━━━━╇━━━━━━━━━━━━━┩ - │ John Doe │ 30 │ New York │ - │ Jane Smith │ 25 │ Los Angeles │ - │ Tim de Jager │ 35 │ Utrecht │ - └──────────────┴─────┴─────────────┘ - - ''' -# --- -# name: test_doc_pixi_workspaces_pixi_build[python] - ''' - ┏━━━━━━━━━━━━━━┳━━━━━┳━━━━━━━━━━━━━┓ - ┃ name ┃ age ┃ city ┃ - ┡━━━━━━━━━━━━━━╇━━━━━╇━━━━━━━━━━━━━┩ - │ John Doe │ 30 │ New York │ - │ Jane Smith │ 25 │ Los Angeles │ - │ Tim de Jager │ 35 │ Utrecht │ - └──────────────┴─────┴─────────────┘ - - ''' -# --- -# name: test_doc_pixi_workspaces_pixi_build[workspace] - ''' - ┏━━━━━━━━━━━━━━┳━━━━━┳━━━━━━━━━━━━━┓ - ┃ name ┃ age ┃ city ┃ - ┡━━━━━━━━━━━━━━╇━━━━━╇━━━━━━━━━━━━━┩ - │ John Doe │ 31 │ New York │ - │ Jane Smith │ 26 │ Los Angeles │ - │ Tim de Jager │ 36 │ Utrecht │ - └──────────────┴─────┴─────────────┘ - - ''' -# --- -# name: test_doc_pixi_workspaces_pixi_build[workspace_variants] - ''' - ┏━━━━━━━━━━━━━━┳━━━━━┳━━━━━━━━━━━━━┓ - ┃ name ┃ age ┃ city ┃ - ┡━━━━━━━━━━━━━━╇━━━━━╇━━━━━━━━━━━━━┩ - │ John Doe │ 31 │ New York │ - │ Jane Smith │ 26 │ Los Angeles │ - │ Tim de Jager │ 36 │ Utrecht │ - └──────────────┴─────┴─────────────┘ - - ''' -# --- diff --git a/tests/integration_python/__snapshots__/test_main_cli.ambr b/tests/integration_python/__snapshots__/test_main_cli.ambr deleted file mode 100644 index 3d991631e5..0000000000 --- a/tests/integration_python/__snapshots__/test_main_cli.ambr +++ /dev/null @@ -1,142 +0,0 @@ -# serializer version: 1 -# name: test_pixi_add_alias - ''' - - [workspace] - name = "test" - channels = [] - platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"] - - [tasks] - dummy-a = [{ task = "dummy-b" }, { task = "dummy-c" }] - - [target.linux-64.tasks] - linux-alias = [{ task = "dummy-b" }, { task = "dummy-c" }] - - ''' -# --- -# name: test_pixi_add_task - ''' - - [workspace] - name = "test" - channels = [] - platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"] - - [tasks] - test = { cmd = "echo 'Hello {{name | title}}'", args = ["name"] } - test-alias = [{ task = "test" }] - - ''' -# --- -# name: test_info_output_extended - dict({ - 'auth_dir': str, - 'cache_dir': str, - 'cache_size': str, - 'config_locations': list, - 'environments_info': list([ - dict({ - 'channels': list([ - 'conda-forge', - ]), - 'dependencies': list([ - ]), - 'environment_size': str, - 'features': list([ - 'default', - ]), - 'name': 'default', - 'platforms': list, - 'prefix': str, - 'pypi_dependencies': list([ - ]), - 'solve_group': None, - 'system_requirements': dict({ - 'archspec': None, - 'cuda': None, - 'libc': None, - 'linux': None, - 'macos': None, - }), - 'tasks': list([ - ]), - }), - dict({ - 'channels': list([ - 'conda-forge', - ]), - 'dependencies': list([ - 'python', - ]), - 'environment_size': str, - 'features': list([ - 'py312', - 'default', - ]), - 'name': 'py312', - 'platforms': list, - 'prefix': str, - 'pypi_dependencies': list([ - ]), - 'solve_group': None, - 'system_requirements': dict({ - 'archspec': None, - 'cuda': None, - 'libc': None, - 'linux': None, - 'macos': None, - }), - 'tasks': list([ - ]), - }), - ]), - 'global_info': dict({ - 'bin_dir': str, - 'env_dir': str, - 'manifest': str, - }), - 'platform': str, - 'project_info': dict({ - 'last_updated': str, - 'manifest_path': str, - 'name': 'test', - 'pixi_folder_size': str, - 'version': None, - }), - 'version': str, - 'virtual_packages': list, - }) -# --- -# name: test_pixi_task_list_json - list([ - dict({ - 'environment': 'default', - 'features': list([ - dict({ - 'name': 'default', - 'tasks': list([ - dict({ - 'args': list([ - dict({ - 'default': 'World', - 'name': 'name', - }), - ]), - 'clean_env': False, - 'cmd': "echo 'Hello {{name | title}}'", - 'cwd': None, - 'depends_on': list([ - ]), - 'description': None, - 'env': None, - 'inputs': None, - 'name': 'test-task', - 'outputs': None, - }), - ]), - }), - ]), - }), - ]) -# --- diff --git a/tests/integration_python/test_docs_examples.py b/tests/integration_python/test_docs_examples.py index 1b0fbcf7ad..06a0e4e42d 100644 --- a/tests/integration_python/test_docs_examples.py +++ b/tests/integration_python/test_docs_examples.py @@ -3,7 +3,7 @@ from pathlib import Path import pytest -from syrupy.assertion import SnapshotAssertion +from inline_snapshot import snapshot from .common import current_platform, get_manifest, repo_root, verify_cli_command @@ -13,33 +13,118 @@ ) -@pytest.mark.extra_slow -@pytest.mark.parametrize( - "pixi_project", - [ - pytest.param(pixi_project, id=pixi_project.name) - for pixi_project in repo_root() - .joinpath("docs/source_files/pixi_workspaces/pixi_build") - .iterdir() - ], -) -def test_doc_pixi_workspaces_pixi_build( - pixi_project: Path, pixi: Path, tmp_pixi_workspace: Path, snapshot: SnapshotAssertion -) -> None: - # Remove existing .pixi folders - shutil.rmtree(pixi_project.joinpath(".pixi"), ignore_errors=True) - - # Copy to workspace - shutil.copytree(pixi_project, tmp_pixi_workspace, dirs_exist_ok=True) - - # Get manifest - manifest = get_manifest(tmp_pixi_workspace) - - # Run task 'start' - output = verify_cli_command( - [pixi, "run", "--locked", "--manifest-path", manifest, "start"], +class TestPixiBuild: + pixi_projects = list( + repo_root().joinpath("docs/source_files/pixi_workspaces/pixi_build").iterdir() + ) + pixi_projects.sort() + pixi_project_params = [ + ( + pixi_projects[0].name, + ( + pixi_projects[0], + snapshot("3\n"), + ), + ), + ( + pixi_projects[1].name, + ( + pixi_projects[1], + snapshot("3\n"), + ), + ), + ( + pixi_projects[2].name, + ( + pixi_projects[2], + snapshot("""\ +┏━━━━━━━━━━━━━━┳━━━━━┳━━━━━━━━━━━━━┓ +┃ name ┃ age ┃ city ┃ +┡━━━━━━━━━━━━━━╇━━━━━╇━━━━━━━━━━━━━┩ +│ John Doe │ 30 │ New York │ +│ Jane Smith │ 25 │ Los Angeles │ +│ Tim de Jager │ 35 │ Utrecht │ +└──────────────┴─────┴─────────────┘ +"""), + ), + ), + ( + pixi_projects[3].name, + ( + pixi_projects[3], + snapshot("""\ +┏━━━━━━━━━━━━━━┳━━━━━┳━━━━━━━━━━━━━┓ +┃ name ┃ age ┃ city ┃ +┡━━━━━━━━━━━━━━╇━━━━━╇━━━━━━━━━━━━━┩ +│ John Doe │ 30 │ New York │ +│ Jane Smith │ 25 │ Los Angeles │ +│ Tim de Jager │ 35 │ Utrecht │ +└──────────────┴─────┴─────────────┘ +"""), + ), + ), + ( + pixi_projects[4].name, + ( + pixi_projects[4], + snapshot("""\ +┏━━━━━━━━━━━━━━┳━━━━━┳━━━━━━━━━━━━━┓ +┃ name ┃ age ┃ city ┃ +┡━━━━━━━━━━━━━━╇━━━━━╇━━━━━━━━━━━━━┩ +│ John Doe │ 31 │ New York │ +│ Jane Smith │ 26 │ Los Angeles │ +│ Tim de Jager │ 36 │ Utrecht │ +└──────────────┴─────┴─────────────┘ +"""), + ), + ), + ( + pixi_projects[5].name, + ( + pixi_projects[5], + snapshot("""\ +┏━━━━━━━━━━━━━━┳━━━━━┳━━━━━━━━━━━━━┓ +┃ name ┃ age ┃ city ┃ +┡━━━━━━━━━━━━━━╇━━━━━╇━━━━━━━━━━━━━┩ +│ John Doe │ 31 │ New York │ +│ Jane Smith │ 26 │ Los Angeles │ +│ Tim de Jager │ 36 │ Utrecht │ +└──────────────┴─────┴─────────────┘ +"""), + ), + ), + ] + + def test_coverage(self) -> None: + # check that we have covered all example directories + assert len(self.pixi_project_params) == len(self.pixi_projects) + + @pytest.mark.extra_slow + @pytest.mark.parametrize( + "pixi_project,result", + list(map(lambda p: pytest.param(*p[1], id=p[0]), pixi_project_params)), ) - assert output.stdout == snapshot + def test_doc_pixi_workspaces_pixi_build( + self, + pixi_project: Path, + result: str, + pixi: Path, + tmp_pixi_workspace: Path, + ) -> None: + # Remove existing .pixi folders + shutil.rmtree(pixi_project.joinpath(".pixi"), ignore_errors=True) + + # Copy to workspace + shutil.copytree(pixi_project, tmp_pixi_workspace, dirs_exist_ok=True) + + # Get manifest + manifest = get_manifest(tmp_pixi_workspace) + + # Run task 'start' + output = verify_cli_command( + [pixi, "run", "--locked", "--manifest-path", manifest, "start"], + ) + assert output.stdout == result @pytest.mark.extra_slow @@ -105,7 +190,7 @@ def test_pytorch_documentation_examples( def test_doc_pixi_workspaces_minijinja_task_args( - doc_pixi_workspaces: Path, pixi: Path, tmp_pixi_workspace: Path, snapshot: SnapshotAssertion + doc_pixi_workspaces: Path, pixi: Path, tmp_pixi_workspace: Path ) -> None: workspace_dir = doc_pixi_workspaces.joinpath("minijinja", "task_args") @@ -135,4 +220,15 @@ def test_doc_pixi_workspaces_minijinja_task_args( results[task] = output - assert results == snapshot + assert results == snapshot( + { + "task1": "HOI RUBEN\n", + "task2": "hoi ruben\n", + "task3": "hoi Ruben!\n", + "task4": "unix\n", + "task5": """\ +hoi +Ruben +""", + } + ) diff --git a/tests/integration_python/test_main_cli.py b/tests/integration_python/test_main_cli.py index cd4599bca1..d65d119179 100644 --- a/tests/integration_python/test_main_cli.py +++ b/tests/integration_python/test_main_cli.py @@ -6,8 +6,8 @@ from pathlib import Path import pytest -from syrupy.assertion import SnapshotAssertion -from syrupy.matchers import path_type +from dirty_equals import IsStr, IsList +from inline_snapshot import snapshot from .common import ( CURRENT_PLATFORM, @@ -1319,7 +1319,7 @@ def test_pixi_task_list_platforms(pixi: Path, tmp_pixi_workspace: Path) -> None: ) -def test_pixi_add_alias(pixi: Path, tmp_pixi_workspace: Path, snapshot: SnapshotAssertion) -> None: +def test_pixi_add_alias(pixi: Path, tmp_pixi_workspace: Path) -> None: manifest = tmp_pixi_workspace.joinpath("pixi.toml") toml = """ [workspace] @@ -1350,10 +1350,22 @@ def test_pixi_add_alias(pixi: Path, tmp_pixi_workspace: Path, snapshot: Snapshot ] ) - assert manifest.read_text() == snapshot + assert manifest.read_text() == snapshot("""\ +[workspace] +name = "test" +channels = [] +platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"] + +[tasks] +dummy-a = [{ task = "dummy-b" }, { task = "dummy-c" }] -def test_pixi_add_task(pixi: Path, tmp_pixi_workspace: Path, snapshot: SnapshotAssertion) -> None: +[target.linux-64.tasks] +linux-alias = [{ task = "dummy-b" }, { task = "dummy-c" }] +""") + + +def test_pixi_add_task(pixi: Path, tmp_pixi_workspace: Path) -> None: manifest = tmp_pixi_workspace.joinpath("pixi.toml") toml = """ [workspace] @@ -1381,12 +1393,20 @@ def test_pixi_add_task(pixi: Path, tmp_pixi_workspace: Path, snapshot: SnapshotA [pixi, "task", "add", "--depends-on", "test", "--manifest-path", manifest, "test-alias", ""] ) - assert manifest.read_text() == snapshot + assert manifest.read_text() == snapshot("""\ +[workspace] +name = "test" +channels = [] +platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"] -def test_pixi_task_list_json( - pixi: Path, tmp_pixi_workspace: Path, snapshot: SnapshotAssertion -) -> None: +[tasks] +test = { cmd = "echo 'Hello {{name | title}}'", args = ["name"] } +test-alias = [{ task = "test" }] +""") + + +def test_pixi_task_list_json(pixi: Path, tmp_pixi_workspace: Path) -> None: manifest = tmp_pixi_workspace.joinpath("pixi.toml") toml = """ [workspace] @@ -1405,13 +1425,36 @@ def test_pixi_task_list_json( task_data = json.loads(result.stdout) - assert task_data == snapshot + assert task_data == snapshot( + [ + { + "environment": "default", + "features": [ + { + "name": "default", + "tasks": [ + { + "name": "test-task", + "cmd": "echo 'Hello {{name | title}}'", + "description": None, + "depends_on": [], + "args": [{"name": "name", "default": "World"}], + "cwd": None, + "env": None, + "clean_env": False, + "inputs": None, + "outputs": None, + } + ], + } + ], + } + ] + ) @pytest.mark.extra_slow -def test_info_output_extended( - pixi: Path, tmp_pixi_workspace: Path, snapshot: SnapshotAssertion -) -> None: +def test_info_output_extended(pixi: Path, tmp_pixi_workspace: Path) -> None: manifest = tmp_pixi_workspace.joinpath("pixi.toml") toml = """ [workspace] @@ -1434,29 +1477,69 @@ def test_info_output_extended( ) info_data = json.loads(result.stdout) - # Stub out path, size and other dynamic data from snapshot - path_matcher = path_type( + # Stub out path, size and other dynamic data from snapshot() + # samuelcolvin/dirty-equals#116 + IsAnyList = IsList(length=...) # type: ignore[call-overload] + assert info_data == snapshot( { - "auth_dir": (str,), - "cache_dir": (str,), - "cache_size": (str,), - "config_locations": (list,), - "environments_info.0.prefix": (str,), - "environments_info.0.environment_size": (str,), - "environments_info.0.platforms": (list,), - "environments_info.1.prefix": (str,), - "environments_info.1.environment_size": (str,), - "environments_info.1.platforms": (list,), - "global_info.bin_dir": (str,), - "global_info.env_dir": (str,), - "global_info.manifest": (str,), - "platform": (str,), - "project_info.manifest_path": (str,), - "project_info.pixi_folder_size": (str,), - "project_info.last_updated": (str,), - "version": (str,), - "virtual_packages": (list,), + "platform": IsStr, + "virtual_packages": IsAnyList, + "version": IsStr, + "cache_dir": IsStr, + "cache_size": IsStr, + "auth_dir": IsStr, + "global_info": { + "bin_dir": IsStr, + "env_dir": IsStr, + "manifest": IsStr, + }, + "project_info": { + "name": "test", + "manifest_path": IsStr, + "last_updated": IsStr, + "pixi_folder_size": IsStr, + "version": None, + }, + "environments_info": [ + { + "name": "default", + "features": ["default"], + "solve_group": None, + "environment_size": IsStr, + "dependencies": [], + "pypi_dependencies": [], + "platforms": IsAnyList, + "tasks": [], + "channels": ["conda-forge"], + "prefix": IsStr, + "system_requirements": { + "macos": None, + "linux": None, + "cuda": None, + "libc": None, + "archspec": None, + }, + }, + { + "name": "py312", + "features": ["py312", "default"], + "solve_group": None, + "environment_size": IsStr, + "dependencies": ["python"], + "pypi_dependencies": [], + "platforms": IsAnyList, + "tasks": [], + "channels": ["conda-forge"], + "prefix": IsStr, + "system_requirements": { + "macos": None, + "linux": None, + "cuda": None, + "libc": None, + "archspec": None, + }, + }, + ], + "config_locations": IsAnyList, } ) - - assert info_data == snapshot(matcher=path_matcher)