in reply to Mocking with namespace::autoclean and Moose::Exporter
I didn't expect your final solution there to work, but what I think you did was confuse ::autoclean into not removing the function from the package. ::autoclean does heuristic guessing games about where a function came from, so maybe after overriding it with Sub::Override it ends up not getting removed. Personally I prefer namespace::clean since it has a simpler mode of operation.
I think your simplest option is to override the Logger::log_warn at the top of your unit test, globally, and then just work with that.
BEGIN { $override= Sub::Override->new( 'Logger::log_warn' => sub { push @wawrnings, $_[0] if caller eq 'MyObj'; } ) }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Mocking with namespace::autoclean and Moose::Exporter
by choroba (Cardinal) on Nov 15, 2024 at 19:11 UTC | |
by NERDVANA (Priest) on Nov 15, 2024 at 23:14 UTC |