This repository has been archived by the owner on Sep 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
__enter__ was swallowing the exception and returning False #299
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wooo 73 (rounded) |
On further reflection, the additional unit test isn't all that effective -- it looks like only open() was eating exceptions, and we can't test exceptions in MockDriver.open() without defining an optional_arg that FORCES MD.open() to throw something. |
cherry-picked the new unittest stuff into develop and confirmed that it fails there, so we are actually testing something new this time: [bewing:/mnt/d/PyCharm/napalm-base] [napalm] develop ± git checkout -b test_regression
[bewing:/mnt/d/PyCharm/napalm-base] [napalm] test_regression ± git cherry-pick 6ffe8ab222c527c39290cd0e02f08100a25781e2
[test_regression 6549b16] Unit test for context manager exceptions
Author: bewing <nicotine@warningg.com>
Date: Tue Aug 8 19:42:01 2017 -0500
1 file changed, 4 insertions(+), 1 deletion(-)
[bewing:/mnt/d/PyCharm/napalm-base] [napalm] test_regression ± git cherry-pick 1f62ad1efcab796bf792d46d257aa4c2cad099d5
[test_regression 1b32943] Test exception handling in __open__
Author: bewing <nicotine@warningg.com>
Date: Tue Aug 8 20:09:20 2017 -0500
2 files changed, 12 insertions(+)
[bewing:/mnt/d/PyCharm/napalm-base] [napalm] test_regression ± tox
====================================================== FAILURES =======================================================
_________________________________________ TestMockDriver.test_context_manager _________________________________________
self = <test_mock_driver.TestMockDriver object at 0x7f3ec6886cf8>
def test_context_manager(self):
with pytest.raises(napalm_base.exceptions.ConnectionException) as e, \
driver("blah", "bleh", "blih", optional_args=fail_args) as d:
> pass
E Failed: DID NOT RAISE <class 'napalm_base.exceptions.ConnectionException'>
test/unit/test_mock_driver.py:53: Failed
=================================== 1 failed, 66 passed, 37 skipped in 3.37 seconds ===================================
ERROR: InvocationError: '/mnt/d/PyCharm/napalm-base/.tox/py36/bin/py.test'
_______________________________________________________ summary _______________________________________________________
ERROR: py27: commands failed
ERROR: py34: commands failed
ERROR: py35: commands failed
ERROR: py36: commands failed
|
Did some more refactoring, I think this one is good to go. Great work with the test :) |
LGTM |
Thanks for this - I noticed this behavior a few weeks ago in https://github.com/StackStorm-Exchange/stackstorm-napalm - came this close to ripping out our |
dbarrosop
pushed a commit
that referenced
this pull request
Aug 26, 2017
* Validate string before evaluating (#274) * Bump version to 0.24.3 (#275) * Fix napalm validate so identical strings will work (#288) * Correct link under "compliance_report" function (#289) Fixing a bad link in the documentation for "compliance_report" function. * Convert napalm_base testing to tox (#284) * Convert napalm_base testing to tox * Update requirements and travis config * @ogenstad to the rescue * Remove unnecessary conftest.py * Omit unit tests from coverage report * py23 text_type * Search parent modules in load_template If an explicit template_path is not specified, build a list of directories from the class MRO and pass them to FileSystemLoader * load_template unit test fixes * Test search path building * If tox was merged I would've caught this * PEP8 * Didn't use this subclass * pylama * Rename template directory * Add requested value to the validate report (#291) * Clean up search_path creation * __enter__ was swallowing the exception and returning False (#299) * __enter__ was swallowing the exception and returning False * Unit test for context manager exceptions * Test exception handling in __open__ * Refactoring context manager * Remove constraint on _rpc method for MockDriver that requires junos profile (#301) * Implemented generic napalm tool with debugging capabilities (#292) * Implemented cl_napalm_show_tech * Typo * Typo * Hide password * Generalize napalm command tool * Fix help * Added deprecation warnings and rename to napalm * unnecessary * Minor fix * Make pylama happy * py3 requires you to cast keys and values into a list (#300) * Version 0.25.0 (#302)
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Solves #297
Do not merge yet. Looks like old implementation was good for py3.