From: Peter Rabbitson Date: Sun, 25 Jan 2015 10:35:23 +0000 (+0100) Subject: Remove useless INIT blocks from CDBI tests - no changes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a40329c43a1b119bb375ac080ead64a38b44eaa6;p=dbsrgits%2FDBIx-Class-Historic.git Remove useless INIT blocks from CDBI tests - no changes A use() is compile-time even when it is in an INIT block, hence removing the INITs is safe. Do not do it for require() invocations, as it is not clear if the tests rely on the specific order or not (more sleeping dogs left to lie) Read under -w --- diff --git a/t/cdbi/02-Film.t b/t/cdbi/02-Film.t index 5d0f860..7f0d498 100644 --- a/t/cdbi/02-Film.t +++ b/t/cdbi/02-Film.t @@ -6,10 +6,8 @@ use Scalar::Util 'refaddr'; use namespace::clean; $| = 1; -INIT { - use lib 't/cdbi/testlib'; - use Film; -} +use lib 't/cdbi/testlib'; +use Film; ok(Film->can('db_Main'), 'set_db()'); is(Film->__driver, "SQLite", "Driver set correctly"); diff --git a/t/cdbi/04-lazy.t b/t/cdbi/04-lazy.t index 51d6ad5..ca28b07 100644 --- a/t/cdbi/04-lazy.t +++ b/t/cdbi/04-lazy.t @@ -7,10 +7,8 @@ use Test::Warn; # Test lazy loading #---------------------------------------------------------------------- -INIT { - use lib 't/cdbi/testlib'; - use Lazy; -} +use lib 't/cdbi/testlib'; +use Lazy; is_deeply [ Lazy->columns('Primary') ], [qw/this/], "Pri"; is_deeply [ sort Lazy->columns('Essential') ], [qw/opop this/], "Essential"; diff --git a/t/cdbi/06-hasa.t b/t/cdbi/06-hasa.t index 02933cd..3c47caa 100644 --- a/t/cdbi/06-hasa.t +++ b/t/cdbi/06-hasa.t @@ -6,13 +6,9 @@ use DBIx::Class::_Util 'sigwarn_silencer'; @YA::Film::ISA = 'Film'; -#local $SIG{__WARN__} = sub { }; - -INIT { - use lib 't/cdbi/testlib'; - use Film; - use Director; -} +use lib 't/cdbi/testlib'; +use Film; +use Director; Film->create_test_film; ok(my $btaste = Film->retrieve('Bad Taste'), "We have Bad Taste"); diff --git a/t/cdbi/15-accessor.t b/t/cdbi/15-accessor.t index 267916d..f5c0099 100644 --- a/t/cdbi/15-accessor.t +++ b/t/cdbi/15-accessor.t @@ -2,18 +2,16 @@ use strict; use warnings; use Test::More; +use lib 't/cdbi/testlib'; INIT { - #local $SIG{__WARN__} = - #sub { like $_[0], qr/clashes with built-in method/, $_[0] }; - use lib 't/cdbi/testlib'; - require Film; - require Actor; - require Director; + require Film; + require Actor; + require Director; - Actor->has_a(film => 'Film'); - Film->has_a(director => 'Director'); + Actor->has_a(film => 'Film'); + Film->has_a(director => 'Director'); - sub Class::DBI::sheep { ok 0; } + sub Class::DBI::sheep { ok 0; } } # Install the deprecation warning intercept here for the rest of the 08 dev cycle diff --git a/t/cdbi/23-cascade.t b/t/cdbi/23-cascade.t index eb9c3f5..79fed22 100644 --- a/t/cdbi/23-cascade.t +++ b/t/cdbi/23-cascade.t @@ -3,11 +3,9 @@ use warnings; use Test::More; use Data::Dumper; -INIT { - use lib 't/cdbi/testlib'; - use Film; - use Director; -} +use lib 't/cdbi/testlib'; +use Film; +use Director; { # Cascade on delete Director->has_many(nasties => 'Film'); diff --git a/t/cdbi/abstract/search_where.t b/t/cdbi/abstract/search_where.t index a14682f..8c4c629 100644 --- a/t/cdbi/abstract/search_where.t +++ b/t/cdbi/abstract/search_where.t @@ -3,11 +3,8 @@ use Test::More; use strict; use warnings; -INIT { - use lib 't/cdbi/testlib'; - use Film; -} - +use lib 't/cdbi/testlib'; +use Film; Film->create({ Title => $_, Rating => "PG" }) for ("Superman", "Super Fuzz"); Film->create({ Title => "Batman", Rating => "PG13" }); diff --git a/t/cdbi/construct.t b/t/cdbi/construct.t index 1ce8160..103877d 100644 --- a/t/cdbi/construct.t +++ b/t/cdbi/construct.t @@ -2,10 +2,8 @@ use strict; use warnings; use Test::More; -INIT { - use lib 't/cdbi/testlib'; - use Film; -} +use lib 't/cdbi/testlib'; +use Film; { Film->insert({ diff --git a/t/cdbi/copy.t b/t/cdbi/copy.t index 6c079cc..d87b73e 100644 --- a/t/cdbi/copy.t +++ b/t/cdbi/copy.t @@ -2,9 +2,7 @@ use strict; use warnings; use Test::More; -INIT { - use lib 't/cdbi/testlib'; -} +use lib 't/cdbi/testlib'; { package # hide from PAUSE diff --git a/t/cdbi/mk_group_accessors.t b/t/cdbi/mk_group_accessors.t index 08adeef..b3e850a 100644 --- a/t/cdbi/mk_group_accessors.t +++ b/t/cdbi/mk_group_accessors.t @@ -2,10 +2,8 @@ use strict; use warnings; use Test::More; -INIT { - use lib 't/cdbi/testlib'; - require Film; -} +use lib 't/cdbi/testlib'; +INIT { require Film } sub Film::get_test { my $self = shift; diff --git a/t/cdbi/object_cache.t b/t/cdbi/object_cache.t index c349940..f79d26e 100644 --- a/t/cdbi/object_cache.t +++ b/t/cdbi/object_cache.t @@ -4,10 +4,8 @@ use Test::More; $| = 1; -INIT { - use lib 't/cdbi/testlib'; - use Film; -} +use lib 't/cdbi/testlib'; +use Film; plan skip_all => "Object cache is turned off" if Film->isa("DBIx::Class::CDBICompat::NoObjectIndex"); diff --git a/t/cdbi/retrieve_from_sql_with_limit.t b/t/cdbi/retrieve_from_sql_with_limit.t index a73358c..f362896 100644 --- a/t/cdbi/retrieve_from_sql_with_limit.t +++ b/t/cdbi/retrieve_from_sql_with_limit.t @@ -2,10 +2,8 @@ use strict; use warnings; use Test::More; -INIT { - use lib 't/cdbi/testlib'; - use Film; -} +use lib 't/cdbi/testlib'; +use Film; for my $title ("Bad Taste", "Braindead", "Forgotten Silver") { Film->insert({ Title => $title, Director => 'Peter Jackson' });