Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

WWW::Mechanize version differences with confess

by Ineffectual (Scribe)
on Aug 03, 2009 at 23:18 UTC ( [id://785591]=perlquestion: print w/replies, xml ) Need Help??

Ineffectual has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks, I've recently upgraded from WWW::Mechanize 1.30 to 1.58 (current version). However, this is causing one of my tests to fail because there's some difference with how the new version responds to confess. I was hoping someone more familiar with WWW::Mechanize can point out to me if there's a way to make the new version act like the old version used to or how to upgrade my test to make the version of WWW::Mechanize not matter.

Test code:
use WWW::Mechanize; use Test::More qw /no_plan/; my $base = 'myuri'; # fake value my $mech = WWW::Mechanize->new; my $form_name = 'searchform'; my $field_name = 'search'; my $term = ''; $mech->get($base); $mech->submit_form( form_name => $form_name, fields => { $field_name => $term}, ); ok($mech->status == 400,'empty searches should have a 400 status'); ok($mech->content =~ /no search term/i, 'and a chide about having no s +earch term');

My perl module that catches the empty search entry looks like:
sub chide { my $self = shift; my $chide_msg = shift; $chide_msg=~s/\n/<br>/gm; # "\n"'s can sometimes totally confuse + the headers; weird, but true my $page_title = shift; warn __PACKAGE__,"::error_page:chide: msg is '$chide_msg'" if $EN +V{DEBUG}; $self->_vars->{page_template} = $self->_vars->{chide_template}; $self->_vars->{chiding} = $chide_msg; $self->_vars->{page_title} = $page_title if $page_title; $self->_vars->{status} = "400 $chide_msg "; # HTTP status code 400 + = 'Bad Request' $self->process; confess $chide_msg if $self->exit_on_error; }
The page rendering is complicated (of course) but works just fine in a web browser. The confess is to make sure that the chide that got called (likely in the middle of another perl module) prevents that perl module from continuing to process.
In version 1.30 this works fine, but in 1.58 it passes the confess out to my test and my test confesses as well!

This appears to be a WWW::Mechanize difference because I installed 1.30 from the CPAN archive and the test works fine again without any further changes. Thanks for any help!

Replies are listed 'Best First'.
Re: WWW::Mechanize version differences with confess
by jbt (Chaplain) on Aug 04, 2009 at 02:27 UTC
    From the Changelog:

    1.52 Tue Nov 25 09:52:30 CST 2008 ======================================== [FIXED] Improved some error messages in $mech->submit_form(). Thanks to Norbert Buchmuller.
      Yeah, I saw that, but I wasn't sure how to figure out what had been done or where to go. I guess I can compare the differences between the subroutines in my 1.30 and my 1.58 versions? Maybe I can find the 1.52 patch somewhere?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://785591]
Approved by broomduster
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (9)
As of 2024-04-23 08:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found