This is turning into quite the pickle.
Packages that are contained within other packages (in-line) have a simple solution (which only works if the 2nd package is a subset of the main page - IE: DBI::db is found in DBI.pm).
What makes what you're attempting to do even worse is that DBI::db is dynamically created - in a very conscience manner - it doesn't simple override the symbol table, but appears to add to it. This is making for some fun while I'm trying to find a good way around this.
So currently I'm looking at 3 scenarios:
1) simple in-line packages where the 'sub' package is contained in the file of the main package which is contained in the same name space. This just needs some documented examples.
2) in-line packages which is not in the same name space as the 'main' package. This will need some more information provided in the new() call - not sure what I'd call it yet. Maybe 'parent_package'?
3) modules that muck around in the symbol table after the fact - which is what DBI seems to be doing. Not sure how to handle this yet.
Thank you for finding this!
Erik
On Wed May 21 05:30:43 2014, TINITA wrote:
Show quoted text> Hi,
> thanks for this nice and simple module.
> I have a tiny problem with mocking $dbh->quote.
>
> my $mock = Test::Mock::Simple->new(module => 'DBI::db');
>
> => Can't locate DBI/db.pm in @INC
>
> DBI::db is not in its own file, but in DBI.pm.
>
> I don't have a good idea how to get around that exept checking if the
> namespace
> %DBI::db:: contains anything and in that case ignore the error message
> from require.
>
> What do you think?
>
> As a workaround I'm doing sub DBI::db::quote { ... }