Skip to content

Commit

Permalink
Python: Move tests outside of src directory
Browse files Browse the repository at this point in the history
Tests shouldn't be shipped with the Python NVTX package.
With this commit, test_profiler.pyx is not included in the wheel
anymore.

More information about test layout: https://docs.pytest.org/en/7.1.x/explanation/goodpractices.html#choosing-a-test-layout-import-rules
  • Loading branch information
guysz-nvidia committed Nov 13, 2024
1 parent 372a784 commit 272fafb
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cibw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ jobs:
CIBW_ARCHS_LINUX: ${{ matrix.cibw_archs_linux }}
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
CIBW_TEST_COMMAND: "pytest {package}/nvtx/tests"
CIBW_TEST_REQUIRES: "pytest"
CIBW_TEST_COMMAND: "pytest {package}/tests"
CIBW_TEST_REQUIRES: "pytest Cython"
CIBW_REPAIR_WHEEL_COMMAND_LINUX: 'auditwheel repair -w {dest_dir} {wheel}'
CIBW_ENVIRONMENT: "C_INCLUDE_PATH=$(pwd)/c/include"
with:
Expand Down
51 changes: 0 additions & 51 deletions python/src/nvtx/tests/test_cython.py

This file was deleted.

Empty file.
File renamed without changes.
21 changes: 21 additions & 0 deletions python/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from Cython.Build import cythonize
from Cython.Build.Cythonize import run_distutils
from pathlib import Path
from setuptools.extension import Extension


def build_cython():
"""Compile Cython files inside tests/cython"""
tests_dir = Path(__file__).parent
cython_dir = tests_dir / 'cython'
include_dir = tests_dir.parent.parent / 'c' / 'include'
run_distutils((
str(cython_dir),
cythonize(
Extension('*', sources=[str(cython_dir / '*.pyx')], include_dirs=[str(include_dir)]),
compiler_directives=dict(language_level=3, embedsignature=True, profile=True))
))


def pytest_configure(config):
build_cython()
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions python/tests/test_profiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .cython.test_profiler import test_profiler_message as _test_profiler_message


def test_profiler():
_test_profiler_message()

0 comments on commit 272fafb

Please sign in to comment.