$mech->autocheck( true | false )

61 views
Skip to first unread message

mintywalker

unread,
Feb 24, 2012, 7:18:37 AM2/24/12
to WWW::Mechanize users
Hi,

I've found myself wanting to do this:

my $mech = WWW::Mechanize( autocheck => 0 );
# run some tests that we know might 404 etc
$mech->autocheck( 1 );
# run more tests that we expect to never error

Is that silly? Should I just be creating a second Mechanize object
instance?

I think it's simple enough to implement, as "$mech->{autocheck} = [1|
0]" ought to suffice?

For instance ... I'd like to create a sub-class of
Test::WWW::Mechanize, which can implement a suite of my own tests ...
some of which I know will 404 etc, but the bulk of which want
autocheck => 1

Or have I just totally missed the obvious and not rtfm properly?

Thanks!

Andy Lester

unread,
Feb 24, 2012, 8:51:59 AM2/24/12
to www-mecha...@googlegroups.com

On Feb 24, 2012, at 6:18 AM, mintywalker wrote:

Or have I just totally missed the obvious and not rtfm properly?

No, there's no method to do it.  It's something that gets requested every so often, though.  Maybe Jesse will add it.

There is no harm in setting $mech->{autocheck} yourself, at least as of this writing.  But we all know how dangerous it is to rely on object internals.

xoxo,
Andy


mintywalker

unread,
Feb 24, 2012, 11:02:22 AM2/24/12
to WWW::Mechanize users
On Feb 24, 1:51 pm, Andy Lester <a...@petdance.com> wrote:
> On Feb 24, 2012, at 6:18 AM, mintywalker wrote:
>
> > Or have I just totally missed the obvious and not rtfm properly?
>
> No, there's no method to do it.  It's something that gets requested every so often, though.  Maybe Jesse will add it.

I've implemented what I think is required, and sent a Pull request.

https://github.com/bestpractical/www-mechanize/pull/8

If I've missed anything, do please point me in the right direction

Murray.

Andy Lester

unread,
Feb 24, 2012, 11:04:25 AM2/24/12
to www-mecha...@googlegroups.com

On Feb 24, 2012, at 10:02 AM, mintywalker wrote:

https://github.com/bestpractical/www-mechanize/pull/8

If I've missed anything, do please point me in the right direction

It looks good to me, especially that you've updated the t/autocheck.t file.  I don't maintain Mech any more, but I don't see any reason why Jesse wouldn't use it.

moregan

unread,
Feb 27, 2012, 2:10:30 PM2/27/12
to WWW::Mechanize users
There is also this patch for Test::WWW::Mechanize:
https://github.com/petdance/test-www-mechanize/issues/10
Reply all
Reply to author
Forward
0 new messages