File: SeqRead_fail.t

package info (click to toggle)
bioperl 1.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 35,788 kB
  • sloc: perl: 94,019; xml: 14,811; makefile: 20
file content (55 lines) | stat: -rw-r--r-- 1,734 bytes parent folder | download | duplicates (2)
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
# -*-Perl-*- Test Harness script for Bioperl
# $Id$

use strict;

BEGIN {
    use Bio::Root::Test;

    test_begin(-tests => 12,
               -requires_modules => [qw(IO::String
                                        LWP::UserAgent
                                        HTTP::Request::Common)],
               -requires_networking => 1);
}

my $verbose = test_debug();

sub fetch {
    my ($id, $class) = @_;
    print "###################### $class  ####################################\n" if $verbose;
    my $seq;
    ok defined( my $gb = $class->new('-verbose'       => $verbose,
                                     '-delay'         => 0,
                                     '-retrievaltype' => 'tempfile') ), "defined for $class";

    if ($class eq 'Bio::DB::SwissProt') {
        test_skip(-tests => 1, -requires_module => 'Data::Stag');
        next if $@;
    }

    eval { $seq = $gb->get_Seq_by_id($id) };
    if ($@ || !defined $seq) {
        ok 1, "error or undef for $class";
        return;
    }
    ok 0, "failure for $class";
}

my @classes = qw( Bio::DB::BioFetch Bio::DB::GenBank Bio::DB::GenPept
                  Bio::DB::SwissProt Bio::DB::RefSeq Bio::DB::EMBL );

my $id = 'XXX111';  # nonsense id

## This is really stupid since many of this modules are not longer
## part of this distribution.  However, they are split over many
## distributions and we don't want to have this test code duplicated
## all over the place.  We should instead have this a Bio::Test module
## but that's work.  See bioperl-live issue #290
for my $class (@classes) {
    SKIP: {
        eval "require $class";
        skip "failed to use $class (guessing it's not available)", 2 if $@;
        fetch($id, $class);
    }
}