-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add del method * Add unittest * Satisfy black formatter * Satisfy pylint linter * PR feedback Co-authored-by: Felix Divo <4403130+felixdivo@users.noreply.github.com> * PR feedback Co-authored-by: Felix Divo <4403130+felixdivo@users.noreply.github.com> * Move to cls attribute * Add unittest * Call parent shutdown from socketcand * Wrap del in try except * Call parent shutdown from ixxat * Black & pylint * PR feedback Co-authored-by: Felix Divo <4403130+felixdivo@users.noreply.github.com> * Remove try/except & fix ordering * Fix unittest * Call parent shutdown from etas * Add warning filter * Make multicast_udp back2back test more specific * clean up test_interface_canalystii.py * carry over from #1519 * fix AttributeError --------- Co-authored-by: TJ Bruno <tj.bruno@everactive.com> Co-authored-by: Felix Divo <4403130+felixdivo@users.noreply.github.com> Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com>
- Loading branch information
1 parent
740c50c
commit 7855da1
Showing
9 changed files
with
94 additions
and
23 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import importlib | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
import can | ||
from can.interfaces import BACKENDS | ||
|
||
|
||
@pytest.fixture(params=(BACKENDS.keys())) | ||
def constructor(request): | ||
mod, cls = BACKENDS[request.param] | ||
|
||
try: | ||
module = importlib.import_module(mod) | ||
constructor = getattr(module, cls) | ||
except: | ||
pytest.skip("Unable to load interface") | ||
|
||
return constructor | ||
|
||
|
||
@pytest.fixture | ||
def interface(constructor): | ||
class MockInterface(constructor): | ||
def __init__(self): | ||
pass | ||
|
||
def __del__(self): | ||
pass | ||
|
||
return MockInterface() | ||
|
||
|
||
@patch.object(can.bus.BusABC, "shutdown") | ||
def test_interface_calls_parent_shutdown(mock_shutdown, interface): | ||
try: | ||
interface.shutdown() | ||
except: | ||
pass | ||
finally: | ||
mock_shutdown.assert_called() |
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