File: test_dependencies.py

package info (click to toggle)
python-pyani 0.2.10-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 159,800 kB
  • sloc: python: 3,111; makefile: 86; sh: 30
file content (82 lines) | stat: -rw-r--r-- 1,809 bytes parent folder | download | duplicates (3)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python

"""Tests for availability of pyani dependencies

We only test for dependencies from non-standard libraries.

These tests are intended to be run using the nose package
(see https://nose.readthedocs.org/en/latest/).
"""

import subprocess
import sys

from nose.tools import assert_equal, nottest


def test_import_biopython():
    """Test Biopython import."""
    import Bio


def test_import_matplotlib():
    """Test matplotlib import."""
    import matplotlib


def test_import_numpy():
    """Test numpy import."""
    import numpy


def test_import_pandas():
    """Test pandas import."""
    import pandas


def test_import_scipy():
    """Test scipy import."""
    import scipy


def test_run_blast():
    """Test that BLAST+ is runnable."""
    cmd = "blastn -version"
    result = subprocess.run(
        cmd,
        shell=sys.platform != "win32",
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        check=True,
    )
    print(result.stdout)
    assert_equal(result.stdout[:6], b"blastn")


@nottest
def test_run_blastall():
    """Test that legacy BLAST is runnable."""
    cmd = "blastall"
    # Can't use check=True, as blastall without arguments returns 1!
    result = subprocess.run(
        cmd,
        shell=sys.platform != "win32",
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
    )
    print(result.stdout)
    assert_equal(result.stdout[1:9], b"blastall")


def test_run_nucmer():
    """Test that NUCmer is runnable."""
    cmd = "nucmer --version"
    result = subprocess.run(
        cmd,
        shell=sys.platform != "win32",
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        check=True,
    )
    print(result.stderr)  # NUCmer puts output to STDERR!
    assert_equal(result.stderr[:6], b"nucmer")