Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Detecting potential attribute access #786

Closed
muratabur opened this issue Mar 15, 2019 · 1 comment
Closed

Question: Detecting potential attribute access #786

muratabur opened this issue Mar 15, 2019 · 1 comment

Comments

@muratabur
Copy link

muratabur commented Mar 15, 2019

Hello,
We are trying to test a large library of functions on heterogeneous data that may or may not have the required attributes for each function.
Do you know of a means to dynamically detect potential attribute access within a function (either in coverage.py or otherwise)?

eg.

def foo(object):
  if object.attr == "x":
    return object.other_attr
  else:
    return object.another_attr

So in this case, we would like to know that object needs to have "attr", "other_attr" and "another_attr" to avoid an AttributeError somewhere.

Thank you!
Murat

@nedbat
Copy link
Owner

nedbat commented Apr 15, 2019

This doesn't sound like something that coverage.py can help with.

@nedbat nedbat closed this as completed Apr 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants