tests.test_pyproject moduleΒΆ

Tests for pyproject.toml utilities.

tests.test_pyproject.test_get_project_name_from_cwd(tmp_path, monkeypatch)[source]ΒΆ

Test that get_project_name reads from pyproject.toml in CWD.

tests.test_pyproject.test_get_project_name_missing_pyproject(tmp_path, monkeypatch)[source]ΒΆ

Test that get_project_name returns None when no pyproject.toml.

tests.test_pyproject.test_get_project_name_no_project_section(tmp_path, monkeypatch)[source]ΒΆ

Test that get_project_name returns None when no [project] section.

tests.test_pyproject.test_get_project_name_with_preloaded_data()[source]ΒΆ

Test that get_project_name accepts pre-parsed pyproject data.

tests.test_pyproject.test_is_python_project(tmp_path, content, expected)[source]ΒΆ

Only a valid PEP 621 [project] table makes a Python project.

tests.test_pyproject.test_is_python_project_accepts_preloaded_data()[source]ΒΆ

is_python_project accepts a pre-parsed pyproject.toml dict.

tests.test_pyproject.PEP621_TABLE = '[project]\nname = "melon-stand"\nversion = "0.1.0"\n'ΒΆ

Minimal valid PEP 621 header the is_python_package cases build on.

tests.test_pyproject.test_is_python_package_reads_uv_opt_out(tmp_path, tool_table, expected)[source]ΒΆ

Only [tool.uv] package = false demotes a PEP 621 project.

tests.test_pyproject.test_is_python_package_implies_is_python_project(tmp_path, content)[source]ΒΆ

A non-Python repo is never a package, whatever [tool.uv] claims.

Locks in the narrowing relation the PACKAGE_ONLY scope depends on: is_python_package can never be True where is_python_project is False, so a PACKAGE_ONLY entry can never outlive a PYTHON_ONLY one.

tests.test_pyproject.test_is_python_package_false_for_missing_pyproject(tmp_path)[source]ΒΆ

A directory with no pyproject.toml builds no package.

tests.test_pyproject.test_is_python_package_accepts_preloaded_data()[source]ΒΆ

is_python_package accepts a pre-parsed pyproject.toml dict.

tests.test_pyproject.test_read_pyproject_toml_survives_file_vanishing_after_check(tmp_path, monkeypatch)[source]ΒΆ

A file disappearing between the existence check and the read yields {}.

The default project_root is relative, so the file can be deleted, or the working directory itself removed, in the window between the two. Both land on the missing-file outcome the docstring already promises, rather than escaping as OSError.

tests.test_pyproject.test_dependency_group_names_reads_the_declared_groups(tmp_path)[source]ΒΆ

Groups come off [dependency-groups], sorted.

tests.test_pyproject.test_extra_names_reads_the_declared_extras(tmp_path)[source]ΒΆ

Extras come off [project.optional-dependencies], sorted.

tests.test_pyproject.test_group_and_extra_names_are_empty_without_a_pyproject(tmp_path)[source]ΒΆ

A directory holding no project declares neither.

tests.test_pyproject.test_cached_toml_parses_once_per_version_of_the_file(tmp_path)[source]ΒΆ

Reads share one parse until the bytes change.

tests.test_pyproject.test_cached_toml_raises_on_a_missing_or_broken_file(tmp_path)[source]ΒΆ

The cache holds parses only: each caller decides what a failure means.

tests.test_pyproject.test_read_pyproject_toml_and_the_lock_share_the_cache(tmp_path)[source]ΒΆ

pyproject.toml and uv.lock read through the same parser.

tests.test_pyproject.test_load_pyproject_doc_is_private_and_editable(tmp_path)[source]ΒΆ

An edit to the editable parse never reaches the shared cached one.

tests.test_pyproject.test_uv_table(tmp_path, content, expected)[source]ΒΆ

The [tool.uv] table reads empty when the project declares none.

tests.test_pyproject.PYPROJECT_BUMPVERSION = '[tool.bumpversion]\ncurrent_version = "4.5.6"\n'ΒΆ

A pyproject.toml declaring its version in the bump-my-version table.

tests.test_pyproject.test_get_current_version(tmp_path, files, expected)[source]ΒΆ

The first bump-my-version source declaring a version wins.

tests.test_pyproject.test_get_current_version_reads_the_working_directory(tmp_path, monkeypatch)[source]ΒΆ

With no root given, the version comes from the working directory.