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_true_for_pep621(tmp_path)[source]ΒΆ

A PEP 621-compliant [project] table qualifies as a Python project.

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

pyproject.toml with only [tool.*] tables is not a Python project.

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

A directory with no pyproject.toml is not a Python project.

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

A pyproject.toml that fails to parse is not a Python project.

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

A [project] table missing required PEP 621 fields is not Python.

[project] with only name (no version, no dynamic) fails the StandardMetadata.from_pyproject validation, so the repo is not considered Python. Locks in the stricter PEP 621 semantics.

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.