Skip to content

Commit

Permalink
test: test coverage of __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nh13 committed Jan 31, 2025
1 parent 0317ec9 commit 3d947c4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
14 changes: 5 additions & 9 deletions pybwa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
from pybwa.libbwamem import * # noqa: F403


def get_include() -> list[str]:
def _get_include() -> list[str]:
"""return a list of include directories."""
dirname = os.path.abspath(os.path.join(os.path.dirname(__file__)))

#
# Header files may be stored in different relative locations
# depending on installation mode (e.g., `python setup.py install`,
# `python setup.py develop`. The first entry in each list is
# `python setup.py develop`). The first entry in each list is
# where develop-mode headers can be found.
#
pybwa_possibilities = [
Expand All @@ -31,18 +30,15 @@ def get_include() -> list[str]:
return includes


def get_defines() -> list[str]:
def _get_defines() -> list[str]:
"""return a list of defined compilation parameters."""
return []


def get_libraries() -> list[str]:
def _get_libraries() -> list[str]:
"""return a list of libraries to link against."""
# Note that this list does not include libcsamtools.so as there are
# numerous name conflicts with libchtslib.so.
dirname = os.path.abspath(os.path.join(os.path.dirname(__file__)))
# pybwa_libs = ['libbwaaln', 'libbwaindex', 'libbwamem']
pybwa_libs = ["libbwaindex"]
pybwa_libs = ["libbwaaln", "libbwaindex", "libbwamem"]

so = sysconfig.get_config_var("EXT_SUFFIX")
return [os.path.join(dirname, x + so) for x in pybwa_libs]
4 changes: 2 additions & 2 deletions tests/_test_libbwaindex.pyxbld
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def make_ext(modname, pyxfilename):
import pybwa
return Extension(name = modname,
sources = [pyxfilename],
include_dirs = pybwa.get_include(),
include_dirs = pybwa._get_include(),
extra_compile_args = [
"-Wno-unused-result",
"-Wno-unreachable-code",
Expand All @@ -15,4 +15,4 @@ def make_ext(modname, pyxfilename):
"-Wno-sign-compare",
"-Wno-error=declaration-after-statement"
],
define_macros = pybwa.get_defines())
define_macros = pybwa._get_defines())
21 changes: 21 additions & 0 deletions tests/test_pybwa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from pathlib import Path

import pybwa


def test_get_includes() -> None:
names = [Path(p).name for p in pybwa._get_include()]
assert names == ["pybwa", "bwa"]


def test_get_defines() -> None:
assert pybwa._get_defines() == []


def test_get_libraries() -> None:
names = [Path(p).name for p in pybwa._get_libraries()]
assert names == [
"libbwaaln.cpython-311-darwin.so",
"libbwaindex.cpython-311-darwin.so",
"libbwamem.cpython-311-darwin.so",
]

0 comments on commit 3d947c4

Please sign in to comment.