nose-knows icon indicating copy to clipboard operation
nose-knows copied to clipboard

Granularity/specificity

Open simon-weber opened this issue 10 years ago • 3 comments

It'd be nice if knows could key on something more specific than filename, since using knows on large files often isn't helpful.

Here's the additional information I can think of:

  1. line numbers (as referenced in https://github.com/eventbrite/nose-knows/issues/2#issuecomment-128087080). easy to get: settrace would have granularity inside functions, setprofile would only have the call/return.
  2. function names. easy to get: frame.f_code.co_name
  3. path above the function (eg package.module.Class.method). harder to get: I think you'd need to get a reference to the function and then the qualified name (which in 2.x may involve parsing the ast, which would be very slow).

Ideally, I'd want 2 + 3 so that keys would be qualified paths. This is about as specific as 1, but more robust to edits (since line numbers change often). But since I think 3 is too slow and 2 is not specific enough by itself (eg in the case of two methods of the same name inside different classes), I think 1+2 may be a good compromise.

Thoughts?

simon-weber avatar Aug 21 '15 16:08 simon-weber

Here is a description of technique (and implementation) where function body checksums are referenced . https://github.com/tarpas/pytest-testmon/wiki/Determining-affected-tests It's quite easy to implement, quick.

tarpas avatar Aug 22 '15 23:08 tarpas

Cool, thanks.

I'm trying out just (file, function_name) with Venmo's code and it seems to be working pretty well.

simon-weber avatar Aug 24 '15 21:08 simon-weber

I think in the short term (file, function_name) sounds like an already huge improvement over just file. Please send on over a pull request and I'll gladly review. If someone needs that granularity around specific lines changed and feels passionate about contributing it, it would be most welcome as well!

eyalr avatar Aug 25 '15 17:08 eyalr