-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure only public entry points are used in tests #196
Comments
To add to this, each test should be able to run on its own. Currently some later tests rely on the side-effects of earlier ones such as initializing the Device. Perhaps a fixture would be the right way to resolve this. |
The current implementation is a module level fixture which set_current()'s the default device. However, this could use some work to more robustly test those methods which do require an initialized context. Some form of function level fixture, which avoids the set-once state of Device._has_inited |
I was being silly, as far as testing is concerned we can totally do this (untested): from cuda.core.experimental import _device
@pytest.fixture(scope="module")
def init_cuda():
device = Device()
device.set_current()
yield
cuda.cuCtxPopCurrent()
with _device._tls_lock:
del _device._tls.devices This ensures:
Then there should be no side effects depending on the test order. WDYT? |
That looks good to me. What I would also add is to have each test explicitly state which fixture it uses rather than rely on the implicit. The use-case this enables is letting us specifying the exact test file to run rather than solely relying on the test filter (i.e. |
Yes I think it's totally doable and is a variant of what I suggested earlier. All we need to do is to change the fixture scope from module to function, and pass it explicitly as a test argument to tests that we need explicitness (not all of them need it I think). |
This also looks good to me. I will update the testsuite and make this change + validate it locally |
ex: we shouldn't call
Stream._init()
in the tests, which is an implementation detail ofcuda.core
. We should only test public APIs.It is fine to also have tests for internal modules/functionalities, but they should come after we have coverage for public APIs.
Originally posted by @leofang in #153 (review)
The text was updated successfully, but these errors were encountered: