File: test_pathlib.py

package info (click to toggle)
python-pybedtools 0.9.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 16,284 kB
  • sloc: python: 10,014; cpp: 899; makefile: 141; sh: 57
file content (33 lines) | stat: -rw-r--r-- 844 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import pathlib

import six

import pybedtools
import pytest


def test_pathlib_base():
    file = "a.bed"
    fn = os.path.join(pybedtools.filenames.data_dir(), file)
    path = pathlib.PurePath(fn)
    assert pybedtools.BedTool(path).fn == fn


def test_pathlib_derived():
    file = "a.bed"
    fn = os.path.join(pybedtools.filenames.data_dir(), file)
    path = pathlib.Path(fn)
    assert pybedtools.BedTool(path).fn == fn


# this may be unnecessary, as the check is performed after str conversion
def test_pathlib_nonexistent_file():
    fn = os.path.join(pybedtools.filenames.data_dir(), "this_file_is_missing")
    path = pathlib.Path(fn)
    if six.PY2:
        with pytest.raises(ValueError):
            pybedtools.BedTool(path)
    else:
        with pytest.raises(FileNotFoundError):
            pybedtools.BedTool(path)