Skip to content

Commit a49af74

Browse files
authored
test: replace cuda driver, device, and context setup with fixtures where relevant (#1293)
* test: replace cuda driver, device, and context setup with fixtures where relevant * test: make ctx an autouse fixture
1 parent a4b285a commit a49af74

File tree

5 files changed

+63
-348
lines changed

5 files changed

+63
-348
lines changed

cuda_bindings/pixi.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cuda_bindings/tests/conftest.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: LicenseRef-NVIDIA-SOFTWARE-LICENSE
3+
4+
import cuda.bindings.driver as cuda
5+
import pytest
6+
7+
8+
@pytest.fixture(scope="module")
9+
def cuda_driver():
10+
(err,) = cuda.cuInit(0)
11+
assert err == cuda.CUresult.CUDA_SUCCESS
12+
13+
14+
@pytest.fixture(scope="module")
15+
def device(cuda_driver):
16+
err, device = cuda.cuDeviceGet(0)
17+
assert err == cuda.CUresult.CUDA_SUCCESS
18+
return device
19+
20+
21+
@pytest.fixture(scope="module", autouse=True)
22+
def ctx(device):
23+
# Construct context
24+
err, ctx = cuda.cuCtxCreate(None, 0, device)
25+
assert err == cuda.CUresult.CUDA_SUCCESS
26+
yield ctx
27+
(err,) = cuda.cuCtxDestroy(ctx)
28+
assert err == cuda.CUresult.CUDA_SUCCESS

0 commit comments

Comments
 (0)