Say you have a function like this:
@ray.remote
def remote_function():
return 1
You maybe can test it like:
def test_remote_function():
ray.init()
x=ray.get(remote_function.remote())
assert x==1
But that means initializing ray without actually needing it (I just want to test the function itself). It does not even have to be async or threaded in my case.
What I do atm is accessing its protected, wrapped function:
def test_remote_function():
assert remote_function._function() == 1
but that feels hacky and the linter disobeys me for it :)
What I'd like is a pytest fixture like so:
def test_remote_function(ray):
x=ray.get(remote_function.remote())
assert x==1
or
def test_remote_function(ray_sync):
x=ray.get(remote_function.remote())
assert x==1
to explicitely make it sync (not use ray actually).
I've seen that ray's internal tests have some sort of pytest fixtures, but not exposed, I guess.
Does anyone know a better way?