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

Disallow inserting attributes into an instance of Session #96

Closed
marcoskirsch opened this issue Jul 27, 2017 · 1 comment
Closed

Disallow inserting attributes into an instance of Session #96

marcoskirsch opened this issue Jul 27, 2017 · 1 comment

Comments

@marcoskirsch
Copy link
Member

marcoskirsch commented Jul 27, 2017

Say you have this code:

def test_take_simple_measurement_works(device_info):
    with nidmm.Session(device_info['name']) as session:
        session.rannge = 50 # Coerces up!
        value = session.read(1000) != 0 # Assumes DMM reading is not exactly zero to support non-

Interestingly, this appears to work, but notice the typo when setting the range property! The range property was never set on the session and no error occurred.

Given that:

I propose that we disallow inserting any attributes into an instance of Session. How to do that is TBD.

@marcoskirsch
Copy link
Member Author

marcoskirsch commented Jul 27, 2017

Defining __setattr__ is most likely the way to go.

texasaggie97-zz pushed a commit that referenced this issue Jul 28, 2017
* "Freeze" the class so no more attributes can be set after __init__ runs
texasaggie97-zz added a commit that referenced this issue Jul 28, 2017
* Fix #96
* "Freeze" the class so no more attributes can be set after __init__ runs
* Need to set current_item in __init__ now that we are freezing the class
* Also showed a hole in unit testing - add test for iteration on modinst session
* Change from '__' to '_
* Update for comments
* Change test name
* Use explicitly non existent property
* Update generated files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant