Skip to content

Do not write to DATA_DIRECTORY in tests - #74

Open
mhucka wants to merge 1 commit into
mainfrom
mh-fix-issue-65
Open

mhucka wants to merge 1 commit into
mainfrom
mh-fix-issue-65

Conversation

@mhucka

@mhucka mhucka commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #65.

This PR prevents tests and transient calculations from attempting to write .hdf5 files into OpenFermion's default data directory (openfermion.config.DATA_DIRECTORY). When OpenFermion is installed in a read-only system location (e.g. system site-packages), tests previously failed with PermissionError.

Changes

  • In generate_molecular_hamiltonian(): pass save=False to run_pyscf() so generating an InteractionOperator does not write molecular data to disk.
  • In tests/_run_pyscf_test.py: scope test_run_pyscf(tmp_path) using pytest's tmp_path fixture for data_directory, remove the unused global molecule definition, and assert that the .hdf5 file is written to the temporary directory.

Testing

Verified with pytest both with DATA_DIRECTORY marked read-only (chmod a-w) and normal permissions:

  • 5 passed in 5.00s

Pass save=False to run_pyscf() in generate_molecular_hamiltonian() so
transient MolecularData objects do not write .hdf5 files to
openfermion's DATA_DIRECTORY.

Update test_run_pyscf() to use pytest's tmp_path fixture and remove the
unused module-level MolecularData object.

Fixes #65.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 tests fail

1 participant