kostyll / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Hook pdb into name interception #118

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The name lookup interception logic in Mock could be used with pdb e.g.

patch.pdb('x.y.z')

could hook a pdb.set_trace() call in to z

Possible options:
 - trace when z is resolved
 - trace when z is called
 - trace on attribute/index access on z

This would allow you to set pdb traces from console (or tests) without having 
to open and edit the source, which is a) is convenient, b) performant (no 
source recompilation), and c) prevents you from accidentally committing 
set_trace() statements in your code :)

Not strictly to do with mocking, but uses the intercept logic.

Wild idea: If this is done and useful, might even be worth splitting out Mock's 
name interception into another package, so other tools could use it?

Original issue reported on code.google.com by bloodear...@gmail.com on 27 Sep 2011 at 4:26

GoogleCodeExporter commented 9 years ago
One possibility would be something like:

    patch.wrap('x.y.z', function=pdb.set_trace)

Original comment by fuzzyman on 27 Sep 2011 at 4:30