tests.test_prebake module¶

Tests for the one-pass dunder baking.

The single-field prebake_dunder and prebake_version helpers are covered in test_version.py, beside the version option that reads what they write. The project metadata readers are covered in test_project.py.

tests.test_prebake.PYPROJECT_SCRIPTS = '[project]\nname = "orchard"\n\n[project.scripts]\norchard = "orchard.cli:main"\n'¶

A pyproject.toml declaring one console script.

tests.test_prebake.src_project(tmp_path)[source]¶

A src-layout project declaring one console script.

Its package carries two empty placeholders: a build field, which always resolves, and a git field, which cannot resolve outside a repository.

tests.test_prebake.test_prebake_dunders_fills_every_empty_placeholder_in_one_pass(tmp_path)[source]¶

Every empty placeholder is filled, and only the resolvers it needs run.

A placeholder already holding a value and a field with no placeholder at all never trigger their resolver, so a build does not shell out for nothing.

tests.test_prebake.test_prebake_dunders_leaves_a_placeholder_its_resolver_cannot_fill(tmp_path)[source]¶

A resolver answering nothing leaves its placeholder, and the file, alone.

tests.test_prebake.test_prebake_dunders_fills_two_placeholders_sharing_a_line(tmp_path)[source]¶

Two literals on one line both land, whatever the first one’s new length.

tests.test_prebake.test_prebake_dunders_writes_a_literal_holding_the_value(tmp_path, placeholder, value, expected)[source]¶

The baked literal parses back to the value, in the quotes it opened with.

A value can carry the quote character the placeholder is written in, like a branch named after a fruit’s owner: escaped, it cannot close the literal early, and the file still compiles.

tests.test_prebake.test_prebake_dunders_counts_columns_past_non_ascii_text(tmp_path)[source]¶

A placeholder after a non-ASCII literal on the same line lands in place.

The parser counts columns in UTF-8 bytes: read as characters, every multi-byte character ahead of the placeholder would shift the splice right.

tests.test_prebake.test_prebake_all_bakes_a_src_layout_project(invoke, src_project, monkeypatch)[source]¶

prebake all finds the package of a src-layout project on its own.

A build field always resolves, so its placeholder proves the file was found and written. The git field stays empty outside a repository.