Skip to content

Share the failure check in project creation tests - #173

Merged
Deicyde merged 2 commits into
mainfrom
golf/project-create-failure-tests
Oct 11, 2026
Merged

Deicyde merged 2 commits into
mainfrom
golf/project-create-failure-tests

Conversation

@Deicyde

@Deicyde Deicyde commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #152 and #162. Test-only: tests/test_project_create.py goes from 2176 to 2039 lines (+85/-222).

  • _fails. The failure tests that call create_project each spelled out pytest.raises, the call with the default package and release, and the code check. _fails(target, code, **options) does that and returns the error for message checks; _refused calls it and keeps its unchanged-parent check. 32 tests now call _fails and 8 more call _refused. The five pytest.raises blocks left call internal helpers, not create_project.
  • Checks that got stronger. Four of the tests moved to _refused check more than before. test_rejects_nonsticky_shared_parent and test_version_conflict_and_floor_messages_name_the_problem now check that the parent is unchanged, and the second also checks its code, project-version-invalid. test_package_name_reserves_the_longest_lake_artifact_filename and test_macos_tmp_alias_is_rejected_but_private_tmp_is_supported compare the whole parent listing instead of checking one name. The other four keep equivalent checks.
  • Interrupt after publish. test_interrupt_after_publish_reports_that_the_target_exists repeated test_fsync_failure_after_publish_reports_that_the_target_exists with KeyboardInterrupt in place of OSError, minus the message checks. The fsync test is now parametrized over both, so the interrupt case checks the message too. create_project calls fsync once after the rename, so raising on the first call after publish, as the fsync test does, covers what the old test's raise-on-every-call did.

No open PR edits this file, and the branch merges cleanly with all 12.

Validation at exact head cd4fee28: ruff check autoform_cli servers tests is clean, and tests/test_project_create.py passes (257).

Most failure tests spelled out pytest.raises, the create_project call and
the code assertion by hand. _fails does that and returns the error;
_refused calls it and keeps its unchanged-parent check. Tests that
asserted an absent target and an empty parent by hand now call _refused.
test_interrupt_after_publish_reports_that_the_target_exists repeated the
fsync failure test with KeyboardInterrupt in place of OSError, minus the
message checks. The fsync test now runs with both, so the interrupt case
also checks the message.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 7, 2026
@Deicyde

Deicyde commented Oct 11, 2026

Copy link
Copy Markdown
Contributor Author

Review at cd4fee2

Verdict: merge-ready. The refactor is test-only and no check got weaker. CI is green at this head.

How it was checked:

  • Same cases. pytest --collect-only at main 89dff279 and at this head both give 257 cases. The only id change is test_interrupt_after_publish_reports_that_the_target_exists, which becomes test_fsync_failure_after_publish_reports_that_the_target_exists[interrupt]. CI selects nothing in this file by node id.
  • Same calls. _fails defaults to package="Project", release_id=_RELEASE, which is what every replaced call passed explicitly. In test_workspace_substitution_fails_before_publication, versions always carries release_id. The surrogate test now passes a Path where it used to pass os.fspath(...). _validate_target calls os.fspath first (autoform_cli/project/create.py:452), so it sees the same string.
  • Same checks.
    • Every replaced block keeps its exception type (ProjectCreateError), its code check and its message checks. One test used to compare (code, message) as a tuple; it now checks the code in _fails and the message after.
    • The 8 tests moved to _refused add a parent-listing comparison. That comparison covers each per-file check it replaces. In the two symlink tests, real starts empty, so listing through the link is the old not list(real.iterdir()).
    • Of the 8, test_never_overwrites_existing_target is also stronger than the description says: the old file-only snapshot missed a leftover empty stage directory, and the listing catches it.
  • Interrupt merge.
    • After the rename, create_project calls os.fsync only once (create.py:219). The except BaseException and finally paths call only _publication_state and os.close. So raising on every fsync after publish (old) and raising on the first one (new) exercise the same path.
    • The interrupt case now also checks both message strings. They follow from _commit_uncertain("target", False, None) (create.py:281).
  • Remaining pytest.raises blocks. The five left call internal helpers (_load_creation_release_descriptor, _parse_release_bundle, _reopen_bound_parent, _rename_noreplace, _open_parent), not create_project, as the description says.

Landing

Posted by PR swarm: Review #173 #174 #180

@Deicyde
Deicyde marked this pull request as ready for review October 11, 2026 02:47
@Deicyde
Deicyde merged commit 4e7a331 into main Oct 11, 2026
9 checks passed
@Deicyde
Deicyde deleted the golf/project-create-failure-tests branch October 11, 2026 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant