Closed pvandyken closed 1 month ago
This more complicated than I thought, for pytest whenever fakefs_tmp is used it seems that the global pathlib.Path class is mocked by a pyfakefs' fake_pathlib.FakePathlibPathModule object, which causes issues since UPath.__init__()
uses some hacks to get its superclass Path to initialize a new UPath instance. This will throw a TypeError with the following code I added to e.g. test_generate_inputs.py
def test_upath(fakefs_tmpdir: Path):
from upath import UPath
UPath('/some/linux/path') # raises an exception where this shouldn't
Any idea how to resolve this issue?
I also see many tests failing with Data generation is extremely slow: Only produced 9 valid examples in 1.02 seconds (5 invalid ones and 0 exceeded maximum size). Try decrea…
, is this expected? This happens when I run (OS: on both Windows and WSL)
poetry run poe test -n 6 -m "not docker"
Edit: Note this problem only exists if we have replaced all Path as UPath in the pybids repo. I'm also opening a PR for changes allowing the repo to support UPath.
This more complicated than I thought, for pytest whenever fakefs_tmp is used it seems that the global pathlib.Path class is mocked by a pyfakefs' fake_pathlib.FakePathlibPathModule object, which causes issues since UPath.init() uses some hacks to get its superclass Path to initialize a new UPath instance. This will throw a TypeError with the following code I added to e.g. test_generate_inputs.py
I wouldn't test with UPath
specifically. At most, just make a very light subclass of Path
that doesn't change anything (actually, Path
itself has some "hacks" so subclassing it may not be straightforward. Python 3.12 introduces the with_segments
method that makes this much easier, so possibly just run the test in python 3.12 and higher.
I also see many tests failing with Data generation is extremely slow: Only produced 9 valid examples in 1.02 seconds (5 invalid ones and 0 exceeded maximum size). Try decrea…, is this expected? This happens when I run (OS: on both Windows and WSL)
Unfortunately this is rather normal. On the gh-actions testing I have all the time limits disabled so it doesn't pop up. At some point it probably would be good to go through and address some of these more specifically, but it's not high priority. For now, I recommend not running the entire test suite on your machine but just the tests you need, and let the rest run on the server.
Closing this issue as PR has been merged.
Discussed in https://github.com/khanlab/snakebids/discussions/450