From d5cce3da3d5770bc8d5b7b14facdcbec7f6ff4a3 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Fri, 29 Jun 2018 21:21:05 +0200 Subject: [PATCH 01/10] added coverage plugin for pytest and added it to travis CI --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 358d32666..b90a8f19d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,12 +45,12 @@ matrix: install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo bash test/open_vcan.sh ; fi + - travis_retry pip install sphinx codecov pytest-cov - travis_retry pip install .[test] - - travis_retry pip install sphinx script: - - pytest -v --timeout=300 + - pytest -v --timeout=300 --cov=./can/* + # Build Docs with Sphinx - # # -a Write all files - - if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then python -m sphinx -an doc build; fi \ No newline at end of file + - if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then python -m sphinx -an doc build; fi From 53b4c2e99a9a0a1b86ce58e4747c2175bc24b539 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Fri, 29 Jun 2018 21:29:25 +0200 Subject: [PATCH 02/10] getting pytest cov to work --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b90a8f19d..083f4e089 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,7 +49,7 @@ install: - travis_retry pip install .[test] script: - - pytest -v --timeout=300 --cov=./can/* + - pytest -v --timeout=300 --cov=can # Build Docs with Sphinx # -a Write all files From 91470836fce0cb8b238b108fb6cd58522b016e71 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Fri, 29 Jun 2018 21:47:33 +0200 Subject: [PATCH 03/10] cleanups and coverage reports for AppVeyor --- .appveyor.yml | 2 +- .travis.yml | 2 +- setup.py | 15 ++++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 56c97233d..d0a068582 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -28,4 +28,4 @@ install: build: off test_script: - - "pytest -v --timeout=300" + - "pytest -v --timeout=300 --cov=can" diff --git a/.travis.yml b/.travis.yml index 083f4e089..2c29c94b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ matrix: install: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo bash test/open_vcan.sh ; fi - - travis_retry pip install sphinx codecov pytest-cov + - travis_retry pip install sphinx - travis_retry pip install .[test] script: diff --git a/setup.py b/setup.py index a0db6fa57..3d58f3f1e 100644 --- a/setup.py +++ b/setup.py @@ -20,13 +20,18 @@ long_description = f.read() # Dependencies +extras_require = { + 'serial': ['pyserial ~= 3.0'], + 'neovi': ['python-ics >= 2.12'] +} tests_require = [ 'mock ~= 2.0', - 'nose ~= 1.3.7', + 'nose ~= 1.3', 'pytest ~= 3.6', 'pytest-timeout ~= 1.2', - 'pyserial ~= 3.0' + 'pytest-cov ~= 2.5', ] +extras_require['test'] = tests_require setup( # Description @@ -58,11 +63,7 @@ install_requires=[ 'wrapt ~= 1.10', ], - extras_require={ - 'serial': ['pyserial >= 3.0'], - 'neovi': ['python-ics >= 2.12'], - 'test': tests_require - }, + extras_require=extras_require, # Testing test_suite="nose.collector", From ce928a7e8d93169c1d27213dab11e8d9bbed6b57 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Fri, 29 Jun 2018 22:05:11 +0200 Subject: [PATCH 04/10] added extras to test requirment in setup.py --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 3d58f3f1e..116e2686c 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,7 @@ from sys import version_info import re import logging +from itertools import chain from setuptools import setup, find_packages logging.basicConfig(level=logging.WARNING) @@ -31,6 +32,8 @@ 'pytest-timeout ~= 1.2', 'pytest-cov ~= 2.5', ] +for key, requirements in extras_require: + tests_require += requirements extras_require['test'] = tests_require setup( From 0ca3755a3f7b4ee60f3759943f32652ff0c0f2ab Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Fri, 29 Jun 2018 22:10:01 +0200 Subject: [PATCH 05/10] for loop fix --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 116e2686c..85b16b9ee 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ 'pytest-timeout ~= 1.2', 'pytest-cov ~= 2.5', ] -for key, requirements in extras_require: +for key, requirements in extras_require.items(): tests_require += requirements extras_require['test'] = tests_require From 9621a29e4ea80b97412d730970099d4ad84785b0 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Fri, 29 Jun 2018 23:47:21 +0200 Subject: [PATCH 06/10] catch exception in ICS find devices --- can/interfaces/ics_neovi/neovi_bus.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/can/interfaces/ics_neovi/neovi_bus.py b/can/interfaces/ics_neovi/neovi_bus.py index 6b164a0b0..918ddf6ec 100644 --- a/can/interfaces/ics_neovi/neovi_bus.py +++ b/can/interfaces/ics_neovi/neovi_bus.py @@ -149,9 +149,13 @@ def _detect_available_configs(): if ics is None: return [] # TODO: add the channel(s) - return [{ - 'serial': NeoViBus.get_serial_number(device) - } for device in ics.find_devices()] + try: + return [{ + 'serial': NeoViBus.get_serial_number(device) + } for device in ics.find_devices()] + except Exception as e: + logger.debug("Failed to detect configs: %s", e) + return [] def _find_device(self, type_filter=None, serial=None): if type_filter is not None: From 65b5eb392250d590fdfa76a1fb53df5f85361856 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sat, 30 Jun 2018 00:16:35 +0200 Subject: [PATCH 07/10] finer grained dependencies --- .appveyor.yml | 2 +- setup.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index d0a068582..067002d08 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -23,7 +23,7 @@ install: - set PATH=%PYTHON_INSTALL%\\Scripts;%PATH% # We need to install the python-can library itself - - "python -m pip install .[test]" + - "python -m pip install .[test,neovi]" build: off diff --git a/setup.py b/setup.py index 85b16b9ee..dfc322c2a 100644 --- a/setup.py +++ b/setup.py @@ -31,9 +31,9 @@ 'pytest ~= 3.6', 'pytest-timeout ~= 1.2', 'pytest-cov ~= 2.5', -] -for key, requirements in extras_require.items(): - tests_require += requirements +] + extras_require['serial'] +#for key, requirements in extras_require.items(): +# tests_require += requirements extras_require['test'] = tests_require setup( From 36361d149e65839bf987c20cbbed3f4366bdf851 Mon Sep 17 00:00:00 2001 From: Brian Thorne Date: Sat, 30 Jun 2018 10:11:40 +1000 Subject: [PATCH 08/10] Add codecov to travis --- .travis.yml | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2c29c94b7..9ce11410d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,7 @@ install: script: - pytest -v --timeout=300 --cov=can - + - codecov # Build Docs with Sphinx # -a Write all files - if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then python -m sphinx -an doc build; fi diff --git a/setup.py b/setup.py index dfc322c2a..b55c695bc 100644 --- a/setup.py +++ b/setup.py @@ -31,6 +31,7 @@ 'pytest ~= 3.6', 'pytest-timeout ~= 1.2', 'pytest-cov ~= 2.5', + 'codecov ~= 2.0' ] + extras_require['serial'] #for key, requirements in extras_require.items(): # tests_require += requirements From cdcb61239149353d478099069d087e89717fbcea Mon Sep 17 00:00:00 2001 From: Brian Thorne Date: Sat, 30 Jun 2018 10:31:53 +1000 Subject: [PATCH 09/10] Add codecov to appveyor --- .appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.appveyor.yml b/.appveyor.yml index 067002d08..e8f718fbb 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -29,3 +29,4 @@ build: off test_script: - "pytest -v --timeout=300 --cov=can" + - "codecov" From cc12faf65a210df5d16cb4c26306a12b7b67c2e7 Mon Sep 17 00:00:00 2001 From: Felix Divo Date: Sun, 1 Jul 2018 17:10:28 +0200 Subject: [PATCH 10/10] fix requested changes --- can/interfaces/ics_neovi/neovi_bus.py | 14 +++++++++----- setup.py | 5 ++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/can/interfaces/ics_neovi/neovi_bus.py b/can/interfaces/ics_neovi/neovi_bus.py index 918ddf6ec..7ede85909 100644 --- a/can/interfaces/ics_neovi/neovi_bus.py +++ b/can/interfaces/ics_neovi/neovi_bus.py @@ -136,7 +136,7 @@ def get_serial_number(device): def shutdown(self): super(NeoViBus, self).shutdown() ics.close_device(self.dev) - + @staticmethod def _detect_available_configs(): """Detect all configurations/channels that this interface could @@ -148,15 +148,19 @@ def _detect_available_configs(): """ if ics is None: return [] - # TODO: add the channel(s) + try: - return [{ - 'serial': NeoViBus.get_serial_number(device) - } for device in ics.find_devices()] + devices = ics.find_devices() except Exception as e: logger.debug("Failed to detect configs: %s", e) return [] + # TODO: add the channel(s) + return [{ + 'interface': 'neovi', + 'serial': NeoViBus.get_serial_number(device) + } for device in devices] + def _find_device(self, type_filter=None, serial=None): if type_filter is not None: devices = ics.find_devices(type_filter) diff --git a/setup.py b/setup.py index b55c695bc..c9cf2cf7c 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,6 @@ from sys import version_info import re import logging -from itertools import chain from setuptools import setup, find_packages logging.basicConfig(level=logging.WARNING) @@ -25,6 +24,7 @@ 'serial': ['pyserial ~= 3.0'], 'neovi': ['python-ics >= 2.12'] } + tests_require = [ 'mock ~= 2.0', 'nose ~= 1.3', @@ -33,8 +33,7 @@ 'pytest-cov ~= 2.5', 'codecov ~= 2.0' ] + extras_require['serial'] -#for key, requirements in extras_require.items(): -# tests_require += requirements + extras_require['test'] = tests_require setup(