コード例 #1
0
ファイル: test_helper.py プロジェクト: sherrillmix/dnapy
def test_readSimpleCsv(tmpdir):
    d = tmpdir.mkdir('dir')
    p = d.join('test.txt')
    with pytest.raises(argparse.ArgumentTypeError):
        helper.checkFile(str(p))
    with helper.openNormalOrGz(str(p),'w') as f:
        f.write("1,'2',3   \n  \n  \na,\"bb\",ccc\n  2,3,4  ")
    assert(helper.readSimpleCsv(str(p))==[['1','2','3'],['a','bb','ccc'],["2","3","4"]])
    with helper.openNormalOrGz(str(p),'w') as f:
        f.write("1,2,3\n\n  \na,bb,ccc,d\n  2,3,4  ")
    with pytest.raises(ValueError):
        helper.readSimpleCsv(str(p))
コード例 #2
0
def test_readSimpleCsv(tmpdir):
    d = tmpdir.mkdir('dir')
    p = d.join('test.txt')
    with pytest.raises(argparse.ArgumentTypeError):
        helper.checkFile(str(p))
    with helper.openNormalOrGz(str(p), 'w') as f:
        f.write("1,'2',3   \n  \n  \na,\"bb\",ccc\n  2,3,4  ")
    assert (helper.readSimpleCsv(str(p)) == [['1', '2',
                                              '3'], ['a', 'bb', 'ccc'],
                                             ["2", "3", "4"]])
    with helper.openNormalOrGz(str(p), 'w') as f:
        f.write("1,2,3\n\n  \na,bb,ccc,d\n  2,3,4  ")
    with pytest.raises(ValueError):
        helper.readSimpleCsv(str(p))
コード例 #3
0
ファイル: test_helper.py プロジェクト: sherrillmix/dnapy
def test_checkFile(tmpdir):
    d = tmpdir.mkdir('dir')
    p = d.join('test.txt')
    with pytest.raises(argparse.ArgumentTypeError):
        helper.checkFile(str(d))
    #doesn't exist yet
    with pytest.raises(argparse.ArgumentTypeError):
        helper.checkFile(str(p))
    p.write("test")
    assert helper.checkFile(str(p))==str(p)
    #make unreadable
    os.chmod(str(p),os.stat(str(p)).st_mode & ~stat.S_IREAD)
    with pytest.raises(argparse.ArgumentTypeError):
        helper.checkFile(str(p))
コード例 #4
0
def test_checkFile(tmpdir):
    d = tmpdir.mkdir('dir')
    p = d.join('test.txt')
    with pytest.raises(argparse.ArgumentTypeError):
        helper.checkFile(str(d))
    #doesn't exist yet
    with pytest.raises(argparse.ArgumentTypeError):
        helper.checkFile(str(p))
    p.write("test")
    assert helper.checkFile(str(p)) == str(p)
    #make unreadable
    os.chmod(str(p), os.stat(str(p)).st_mode & ~stat.S_IREAD)
    with pytest.raises(argparse.ArgumentTypeError):
        helper.checkFile(str(p))
    #check pipe
    p = d.join('test.pipe')
    with pytest.raises(argparse.ArgumentTypeError):
        helper.checkFile(str(d))
    os.mkfifo(str(p))
    with pytest.raises(argparse.ArgumentTypeError):
        helper.checkFile(str(p), False)
    assert (helper.checkFile(str(p), True)) == str(p)
    assert (helper.checkFile(str(p))) == str(p)