Skip to content

Conversation

matthewturk
Copy link
Member

This is another WIP experiment. I have taken to heart what @Xarthisius has said for a while about how it would be nice to mock h5py.

This requires a file that can be generated, called mock_hdf5_structure.json that we can use. Here's code for generating a set of them:

https://gist.github.com/matthewturk/5313f6318d89763fd4282f49c654d500

I've also included a fake one in there. You'll need to search-and-replace the path to get it to match yours, but if you then have a .hierarchy and a parameter file next to it, you should be set. Then, interactively,

from conftest import patch_h5py
patch_h5py(None)

import yt
ds = yt.load("Whatever/galaxy0030/galaxy0030")

Right now it'll generate a field list, but I need to properly implement MockH5pyH5d.open and MockH5pyH5d.read before it'll do anything else. I'll give that a go.

This would dramatically reduce the amount of data we'd need. I think with some additional coding we could mock up some other readers, too.

Copy link
Member

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick note: conftest.py shouldn't be used as a module to import stuff from, please use a dedicated module for that

@matthewturk
Copy link
Member Author

Fair point! The import of the mock will need to go in there eventually though, right? So that pytest can pick it up?

Where should I put it to avoid importing yt.whatever -- i.e., having the h5py mock exist outside of it?

(Also that's just in my example script, not planning on having that be used anywhere other than testing the test :) )

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 participants