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!

In reply to WWW::Mechanize version differences with confess by Ineffectual

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.