Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robomics committed Nov 9, 2024
1 parent e1a0426 commit 4b51f85
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/test_file_ctors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (C) 2024 Roberto Rossini <[email protected]>
#
# SPDX-License-Identifier: MIT

import pathlib

import pytest

import hictkpy

testdir = pathlib.Path(__file__).resolve().parent

pytestmark = pytest.mark.parametrize(
"file,resolution",
[
(testdir / "data" / "cooler_test_file.mcool", 100_000),
(testdir / "data" / "hic_test_file.hic", 100_000),
],
)


class TestClass:
def test_resolution_mismatch(self, file, resolution):
f = hictkpy.MultiResFile(file)

if not f[resolution].is_cooler():
pytest.skip(f'File "{file}" is not in .mcool format')

assert 1_000_000 in f.resolutions()
with pytest.raises(RuntimeError, match="resolution mismatch"):
hictkpy.File(f"{file}::/resolutions/{resolution}", 1_000_000)

def test_missing_resolution_param(self, file, resolution):
f = hictkpy.MultiResFile(file)

if f[resolution].is_cooler():
ext = ".mcool"
else:
ext = ".hic"

with pytest.raises(RuntimeError, match=f"resolution is required and cannot be None when opening {ext} files"):
hictkpy.File(file)

0 comments on commit 4b51f85

Please sign in to comment.