Skip to content

Commit

Permalink
TST: Add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Vini2 committed Apr 22, 2024
1 parent 6e6ecc9 commit 4229def
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 7 deletions.
8 changes: 1 addition & 7 deletions tests/test_graphbin2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
import pytest

__author__ = "Vijini Mallawaarachchi"
__copyright__ = "Copyright 2020, GraphBin2 Project"
__credits__ = ["Vijini Mallawaarachchi", "Anuradha Wickramarachchi", "Yu Lin"]
__license__ = "BSD"
__version__ = "1.2.0"
__maintainer__ = "Vijini Mallawaarachchi"
__email__ = "[email protected]"
__status__ = "Development"
__credits__ = ["Vijini Mallawaarachchi"]


TEST_ROOTDIR = Path(__file__).parent
Expand Down
50 changes: 50 additions & 0 deletions tests/test_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import subprocess
from pathlib import Path

import pytest

__author__ = "Vijini Mallawaarachchi"
__credits__ = ["Vijini Mallawaarachchi"]


TEST_ROOTDIR = Path(__file__).parent


@pytest.fixture(scope="session")
def tmp_dir(tmpdir_factory):
return tmpdir_factory.mktemp("tmp")


@pytest.fixture(autouse=True)
def workingdir(tmp_dir, monkeypatch):
"""set the working directory for all tests"""
monkeypatch.chdir(tmp_dir)


def exec_command(cmnd, stdout=subprocess.PIPE, stderr=subprocess.PIPE):
"""executes shell command and returns stdout if completes exit code 0
Parameters
----------
cmnd : str
shell command to be executed
stdout, stderr : streams
Default value (PIPE) intercepts process output, setting to None
blocks this."""

proc = subprocess.Popen(cmnd, shell=True, stdout=stdout, stderr=stderr)
out, err = proc.communicate()
if proc.returncode != 0:
raise RuntimeError(f"FAILED: {cmnd}\n{err}")
return out.decode("utf8") if out is not None else None


def test_gfa2fasta_help():
"""test gfa2fasta help message"""
cmd = "gfa2fasta --help"
exec_command(cmd)


def test_prepResult_help():
"""test prepResult help message"""
cmd = "prepResult --help"
exec_command(cmd)

0 comments on commit 4229def

Please sign in to comment.