예제 #1
0
    def inner():
        inner_reader, inner_writer = get_pipes()
        wrapped = catch_stderr(inner_writer)(stderr_func)

        # make sure value is returned from wrapped function
        msg = wrapped(message)
        assert_equal(message, msg)

        # make sure we caught entire message from stderr
        inner_writer.flush()
        inner_writer.close()
        assert_equal(message, inner_reader.read())
        inner_reader.close()
예제 #2
0
 def inner():
     inner_reader, inner_writer = get_pipes()
     wrapped = catch_stderr(inner_writer)(stderr_func)
     
     # make sure value is returned from wrapped function
     msg = wrapped(message)
     assert_equal(message,msg)
     
     # make sure we caught entire message from stderr
     inner_writer.flush()
     inner_writer.close()
     assert_equal(message,inner_reader.read())
     inner_reader.close()
예제 #3
0
from pkg_resources import resource_filename, cleanup_resources
from plastid.test.functional.base import execute_helper
from plastid.test.ref_files import RPATH, REF_FILES, \
                                             COUNT_OPTIONS, \
                                             ANNOTATION_OPTIONS, \
                                             MASK_OPTIONS  
from plastid.genomics.genome_array import GenomeArray                                             
from plastid.bin.make_wiggle import main
from plastid.util.services.decorators import catch_stderr

#===============================================================================
# INDEX: global constants used by tests
#===============================================================================

test_info = {
    "test_method"    : catch_stderr()(main),
    "module_name"    : "plastid.bin.make_wiggle",
    "ref_file_path"  : resource_filename("plastid","test/data/command_line"),
    "temp_file_path" : tempfile.mkdtemp(prefix="make_wiggle"),
}
"""Constants used in tests below"""

#===============================================================================
# INDEX: programmatically define tests
#===============================================================================

# Define tests as tuples of:
# 1. Command-line style arguments to pass to ``main``
# 2. A list of reference files that output should be compared against
# 3. A list of output files created by running ``main`` with the arguments provided in (1)
# 4. A list of strings specifying how equality should be evaluated
예제 #4
0
from pkg_resources import resource_filename, cleanup_resources
from plastid.test.functional.base import execute_helper
from plastid.test.ref_files import COUNT_OPTIONS, \
                                   ANNOTATION_OPTIONS, \
                                   MASK_OPTIONS  
from plastid.bin.cs import main

from plastid.util.services.decorators import catch_stderr


#===============================================================================
# INDEX: global constants used by tests
#===============================================================================

test_info = {
    "test_method"    : catch_stderr()(main),
    "module_name"    : "plastid.bin.cs",
    "ref_file_path"  : resource_filename("plastid","test/data/command_line"),
    "temp_file_path" : tempfile.mkdtemp(prefix="cs"),
}
"""Constants used by multiple tests"""

_outbase = os.path.join(test_info["temp_file_path"],"test_cs")
_file_stubs = [
                'merged.txt',
                'gene.positions',
                'transcript.positions',

                'gene_cds.bed',
                'gene_exon.bed',
                'gene_masked.bed',
예제 #5
0
파일: base.py 프로젝트: zzygyx9119/plastid
import sys
import shlex
import shutil
import inspect
import os
import nose

from nose.tools import assert_true
from plastid.util.io.filters import NameDateWriter
from plastid.util.io.openers import get_short_name, NullWriter
from plastid.bin.test_table_equality import main
from plastid.util.services.decorators import skip_if_abstract, catch_stderr
from pkg_resources import resource_filename, cleanup_resources

printer = NameDateWriter(get_short_name(inspect.stack()[-1][1]))
table_test = catch_stderr()(main)

#===============================================================================
# INDEX: test generator functions
#===============================================================================


def check_one_file(test_info, ref_file, output_file, eq_args):
    """Check a single output file produced by a test run against a reference file 
    
    Parameters
    ----------
    test_info : dict
        Dictionary containing miscellaneous test information
    
    ref_file : str
예제 #6
0
import sys
import shlex
import shutil
import inspect
import os
import nose

from nose.tools import assert_true
from plastid.util.io.filters import NameDateWriter
from plastid.util.io.openers import get_short_name, NullWriter
from plastid.bin.test_table_equality import main
from plastid.util.services.decorators import skip_if_abstract, catch_stderr
from pkg_resources import resource_filename, cleanup_resources

printer = NameDateWriter(get_short_name(inspect.stack()[-1][1]))
table_test = catch_stderr()(main)

#===============================================================================
# INDEX: test generator functions
#===============================================================================

def check_one_file(test_info,ref_file,output_file,eq_args):
    """Check a single output file produced by a test run against a reference file 
    
    Parameters
    ----------
    test_info : dict
        Dictionary containing miscellaneous test information
    
    ref_file : str
        Name of reference file, excluding path, against which test output will be checked
from tempfile import NamedTemporaryFile
from pkg_resources import cleanup_resources
from nose.plugins.attrib import attr
from nose.tools import assert_equal
from plastid.util.io.filters import CommentWriter
from plastid.util.io.openers import NullWriter
from plastid.genomics.roitools import GenomicSegment
from plastid.bin.test_table_equality import main
from plastid.util.services.decorators import catch_stderr



size = 5000

#capture output
run_main = catch_stderr()(main)

@attr(test="functional")
def test_exit_status():

    # define columns
    cols = {
        "intA"   : numpy.random.randint(0,high=2**16,size=size),
        "intB"   : numpy.random.randint(-10,high=20,size=size),
        "idxA"   : numpy.arange(size),
        "chrA"   : numpy.array([chr(65+(X%(91-65))) for X in range(size)]),
        "strA"   : numpy.array([str(GenomicSegment("chrA",X,X+500,"+")) for X in range(size)]),
        "strB"   : numpy.array([str(GenomicSegment("chrB",X/2,X/2+500,"-")) for X in range(size)]),
        "floatA" : 10*numpy.random.randn(size) + 500,
        "floatB" : (10**-5)*numpy.random.random(size),
        "objA"   : numpy.tile(None,5000),
예제 #8
0
 def inner():
     # make sure value is returned from wrapped function
     wrapped = catch_stderr()(stderr_func)
     msg = wrapped(message)
     assert_equal(msg, message)
예제 #9
0
from plastid.test.functional.base import execute_helper
from plastid.test.ref_files import RPATH, REF_FILES, \
                                              COUNT_OPTIONS, \
                                              ANNOTATION_OPTIONS, \
                                              MASK_OPTIONS
from plastid.bin.get_count_vectors import main
from plastid.util.services.decorators import catch_stderr
from plastid.util.services.mini2to3 import cStringIO

#===============================================================================
# INDEX: global constants used by tests
#===============================================================================

get_count_vectors_test_info = {
    "test_method":
    catch_stderr()(main),
    "module_name":
    "plastid.bin.get_count_vectors",
    "ref_file_path":
    resource_filename("plastid", "test/data/command_line/gen_count_vectors"),
    "temp_file_path":
    tempfile.mkdtemp(prefix="get_count_vectors"),
}

# Define tests as tuples of:
# 1. Command-line style arguments to pass to ``main``
# 2. A list of reference files that output should be compared against
# 3. A list of output files created by running ``main`` with the arguments provided in (1)
# 4. A list of strings specifying how equality should be evaluated
ref_files = []
out_files = []
예제 #10
0
 def inner():
     # make sure value is returned from wrapped function
         wrapped = catch_stderr()(stderr_func)
         msg = wrapped(message)
         assert_equal(msg,message)
예제 #11
0
from pkg_resources import resource_filename, cleanup_resources
from nose.plugins.attrib import attr
from plastid.test.functional.base import execute_helper
from plastid.test.ref_files import RPATH, REF_FILES, \
                                             COUNT_OPTIONS, \
                                             ANNOTATION_OPTIONS, \
                                             MASK_OPTIONS  
from plastid.bin.test_table_equality import main as table_test                               
from plastid.bin.metagene import main
from plastid.util.services.decorators import catch_stderr

#===============================================================================
# INDEX: global constants used by tests
#===============================================================================

TEST_INFO = { "test_method"    : catch_stderr()(main),
              "module_name"    : "plastid.bin.metagene",
              "ref_file_path"  : resource_filename("plastid","test/data/command_line"),
              "temp_file_path" : tempfile.mkdtemp(prefix="metagene"),
             }

_basename = os.path.join(TEST_INFO["temp_file_path"],"test_metagene")

#===============================================================================
# INDEX: tests
#===============================================================================

tests = [
    # test generate cds start
    (
        "generate %s_cds_start --downstream 100 %s %s" % (_basename, ANNOTATION_OPTIONS, MASK_OPTIONS),