Skip to content

Conversation

marcoskirsch
Copy link
Member

[X] This contribution adheres to [CONTRIBUTING.md]

What does this Pull Request accomplish?

  • Fix Getting a error when calling GetError causes a recursion failure #205
  • Adds function add-on metadata that indicates that a function is_error_handling
    • helper.py function fills in the information (default is False) if missing.
  • Marks a few functions as codegen_method : 'No'
    • ClearError()
    • error_message()
    • There are surely more we want to stop generating. That is outside the scope of this PR and will be handled once we work on code coverage for Library in the system tests.
  • Adds is_error_handling parameter to errors.handle_error
    • This way it knows not to try and get error description again.
  • Re-enable and fix unit test that caught this problem in the first place.

Why should this Pull Request be merged?

Bugfixes!

What testing has been done?

Unit tests were run locally (tox)

This allows us to customize behavior based on whether the caller is
“error handling” or not. Specifically, we don’t want to raise if we are
already in the midst of handling an error.
Call to error.handle_error changed with new parameter.
# Conflicts:
#	src/nidmm/metadata/__init__.py
#	src/nifake/metadata/__init__.py
#	src/nimodinst/metadata/__init__.py
The mock expectations weren’t correct.
Because it is used in the context of error handling. It now simply
returns hardcoded description on failure.
* Add docstring
* Add documentation
* Return hardcoded description when cannot get it dynamically
# Conflicts:
#	src/nidmm/metadata/__init__.py
#	src/nifake/metadata/__init__.py
#	src/nimodinst/metadata/__init__.py
@texasaggie97-zz
Copy link
Contributor

============================= test session starts =============================
platform win32 -- Python 3.6.2, pytest-3.2.2, py-1.4.34, pluggy-0.4.0 -- c:\jenkins\workspace\nimi_python_system_tests\.tox\system_tests\scripts\python.exe
cachedir: .cache
rootdir: C:\Jenkins\workspace\nimi_python_system_tests, inifile: tox.ini
collecting ... collected 21 items

bin/niswitch/system_tests/test_system_niswitch.py::test_relayclose PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_channel_connection PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_vi_boolean_attribute PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_vi_string_attribute PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_vi_int32_attribute PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_vi_real64_attribute PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_write_only_attribute PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_method_reset PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_method_set_path PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_method_can_connect PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_method_reset_with_defaults PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_functions_get_relay_name PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_functions_get_channel_name PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_functions_revision_query PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_functions_get_next_coercion_record PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_functions_get_next_interchange_warning PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_functions_self_test PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_functions_get_path PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_functions_error_query PASSED
bin/niswitch/system_tests/test_system_niswitch.py::test_functions_error_message FAILED
bin/niswitch/system_tests/test_system_niswitch.py::test_functions_get_error_description PASSED

================================== FAILURES ===================================
________________________ test_functions_error_message _________________________

session = <niswitch.session.Session object at 0x000002942EB313C8>

    def test_functions_error_message(session):
>       message = session.error_message(-1074126847)
E       AttributeError: 'Session' object has no attribute 'error_message'

bin\niswitch\system_tests\test_system_niswitch.py:144: AttributeError
===================== 1 failed, 20 passed in 0.92 seconds =====================

# Conflicts:
#	docs/nifake/functions.rst
@marcoskirsch
Copy link
Member Author

Interesting, and nice catch by system tests. Will need to figure out why this is not caught by NI-FAKE unit tests.

# Conflicts:
#	docs/nidmm/functions.rst
#	docs/nifake/functions.rst
#	docs/niswitch/functions.rst
This used to test a function that I removed from the generated code,
because there’s no good reason for clients to need it. Generated code
takes care of getting session descriptions internally when an Error is
raised.
@marcoskirsch
Copy link
Member Author

Removed the test that was failing. It was calling the method that I removed. I still think removing is the right thing to do. @Fladolcetta if you disagree let me know.


def _add_is_error_handling(f):
'''Adds is_error_handling information to the function metadata if it isn't already defined. Defaults to False.'''
# TODO(marcoskirsch): The information is added in functions_addon.py. I think we can instead infer from method
Copy link
Contributor

@texasaggie97-zz texasaggie97-zz Sep 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My two <pick your currency> is this way (being explicit) is less error prone.

@texasaggie97-zz texasaggie97-zz merged commit af65d5a into master Sep 10, 2017
@texasaggie97-zz texasaggie97-zz deleted the new/error-handling-functions branch September 10, 2017 19:43
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

Successfully merging this pull request may close these issues.

Getting a error when calling GetError causes a recursion failure

2 participants