Skip to content

Commit ffa8bea

Browse files
authored
Merge branch 'develop' into test-message-sync
2 parents 519fc93 + e8e4522 commit ffa8bea

6 files changed

Lines changed: 63 additions & 40 deletions

File tree

.travis.yml

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
language: python
22

33
python:
4-
# CPython; versions pre-2.7 and 3.0-3.4 have reached EOL
4+
# CPython; versions pre-2.7 and 3.0-3.5 have reached EOL
55
- "2.7"
66
- "3.6"
7-
- "3.7-dev" # TODO: change to "3.7" once it is supported by travis-ci
8-
- "nightly"
7+
- "3.7"
8+
- 3.8-dev
9+
- nightly
910
# PyPy:
10-
- "pypy" # Python 2.7
11-
- "pypy3.5" # Python 3.5
11+
- pypy # Python 2.7
12+
- pypy3.5 # Python 3.5
1213

1314
os:
1415
- linux # Linux is officially supported and we test the library under
@@ -25,39 +26,58 @@ os:
2526
# - windows # Windows is not supported at all by Travis CI as of Feb. 2018
2627

2728
# Linux setup
28-
dist: trusty
29-
sudo: required
29+
dist: xenial
3030

3131
matrix:
32-
# see "os: ..." above
3332
include:
33+
# building the docs
34+
- python: "3.7"
35+
env: BUILD_ONLY_DOCS=TRUE
36+
# testing socketcan on Trusty & Python 3.6, since it is not available on Xenial
37+
- os: linux
38+
dist: trusty
39+
python: "3.6"
40+
sudo: required
41+
env: TEST_SOCKETCAN=TRUE
42+
# testing on macOS; see "os: ..." above
3443
- os: osx
3544
osx_image: xcode8.3
36-
python: "3.6-dev"
45+
python: 3.6-dev
3746
- os: osx
3847
osx_image: xcode8.3
39-
python: "3.7-dev"
48+
python: 3.7-dev
4049
- os: osx
4150
osx_image: xcode8.3
42-
python: "nightly"
51+
python: nightly
4352

4453
allow_failures:
45-
# allow all nighly builds to fail, since these python versions might be unstable
46-
- python: "nightly"
47-
# we do not allow dev builds to fail, since these builds are considered stable enough
54+
# we allow all dev & nighly builds to fail, since these python versions might
55+
# still be very unstable
56+
- python: 3.8-dev
57+
- python: nightly
4858

4959
install:
50-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo bash test/open_vcan.sh ; fi
51-
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then travis_retry pip install -r doc/doc-requirements.txt; fi
60+
- if [[ "$TEST_SOCKETCAN" ]]; then sudo bash test/open_vcan.sh ; fi
61+
- if [[ "$BUILD_ONLY_DOCS" ]]; then travis_retry pip install -r doc/doc-requirements.txt; fi
5262
- travis_retry pip install .[test]
5363

5464
script:
55-
- pytest
56-
- codecov
57-
# Build Docs with Sphinx
58-
# -a Write all files
59-
# -n nitpicky
60-
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]]; then python -m sphinx -an doc build; fi
65+
- |
66+
if [[ "$BUILD_ONLY_DOCS" ]]; then
67+
# Build the docs with Sphinx
68+
# -a Write all files
69+
# -n nitpicky
70+
python -m sphinx -an doc build
71+
else
72+
# Run the tests
73+
python setup.py test
74+
# preserve the error code
75+
RETURN_CODE=$?
76+
# Upload the coverage to codecov.io
77+
codecov
78+
# set error code
79+
(exit $RETURN_CODE);
80+
fi
6181
6282
# Have travis deploy tagged commits to PyPi
6383
deploy:

doc/internal-api.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,15 @@ Ideally add both reading and writing support for the new file format, although t
9090
Besides from a constructor, only ``__iter__(self)`` needs to be implemented.
9191
3. Implement a writer ``CanstoreWriter`` (which often extends :class:`can.io.generic.BaseIOHandler` and :class:`can.Listener`, but does not have to).
9292
Besides from a constructor, only ``on_message_received(self, msg)`` needs to be implemented.
93-
4. Document the two new classes (and possibly additional helpers) with docstrings and comments.
93+
4. Add a case to ``can.io.player.LogReader``'s ``__new__()``.
94+
5. Document the two new classes (and possibly additional helpers) with docstrings and comments.
9495
Please mention features and limitations of the implementation.
95-
5. Add a short section to the bottom of *doc/listeners.rst*.
96-
6. Add tests where appropriate, for example by simply adding a test case called
96+
6. Add a short section to the bottom of *doc/listeners.rst*.
97+
7. Add tests where appropriate, for example by simply adding a test case called
9798
`class TestCanstoreFileFormat(ReaderWriterTest)` to *test/logformats_test.py*.
9899
That should already handle all of the general testing.
99100
Just follow the way the other tests in there do it.
100-
7. Add imports to *can/__init__py* and *can/io/__init__py* so that the
101+
8. Add imports to *can/__init__py* and *can/io/__init__py* so that the
101102
new classes can be simply imported as *from can import CanstoreReader, CanstoreWriter*.
102103

103104

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
url="https://github.com/hardbyte/python-can",
4949
description="Controller Area Network interface module for Python",
5050
long_description=long_description,
51-
classifiers=(
51+
classifiers=[
5252
# a list of all available ones: https://pypi.org/classifiers/
5353
"Programming Language :: Python",
5454
"Programming Language :: Python :: 2.7",
@@ -74,7 +74,7 @@
7474
"Topic :: System :: Networking",
7575
"Topic :: System :: Hardware :: Hardware Drivers",
7676
"Topic :: Utilities"
77-
),
77+
],
7878

7979
# Code
8080
version=version,

test/config.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,25 @@
1212
from os import environ as environment
1313

1414

15+
def env(name): # type: bool
16+
return environment.get(name, '').lower() in ("yes", "true", "t", "1")
17+
18+
1519
# ############################## Continuos integration
1620

1721
# see here for the environment variables that are set on the CI servers:
1822
# - https://docs.travis-ci.com/user/environment-variables/
1923
# - https://www.appveyor.com/docs/environment-variables/
2024

21-
IS_TRAVIS = environment.get('TRAVIS', '').lower() == 'true'
22-
IS_APPVEYOR = environment.get('APPVEYOR', '').lower() == 'true'
25+
IS_TRAVIS = env('TRAVIS')
26+
IS_APPVEYOR = env('APPVEYOR')
2327

24-
IS_CI = IS_TRAVIS or IS_APPVEYOR or \
25-
environment.get('CI', '').lower() == 'true' or \
26-
environment.get('CONTINUOUS_INTEGRATION', '').lower() == 'true'
28+
IS_CI = IS_TRAVIS or IS_APPVEYOR or env('CI') or env('CONTINUOUS_INTEGRATION')
2729

2830
if IS_APPVEYOR and IS_TRAVIS:
2931
raise EnvironmentError("IS_APPVEYOR and IS_TRAVIS cannot be both True at the same time")
3032

33+
3134
# ############################## Platforms
3235

3336
_sys = platform.system().lower()
@@ -42,11 +45,10 @@
4245
"can be True at the same time " +
4346
'(platform.system() == "{}")'.format(platform.system())
4447
)
45-
elif not IS_WINDOWS and not IS_LINUX and not IS_OSX:
46-
raise EnvironmentError("one of IS_WINDOWS, IS_LINUX, IS_OSX has to be True")
48+
4749

4850
# ############################## What tests to run
4951

5052
TEST_CAN_FD = True
5153

52-
TEST_INTERFACE_SOCKETCAN = IS_CI and IS_LINUX
54+
TEST_INTERFACE_SOCKETCAN = IS_LINUX and env('TEST_SOCKETCAN')

test/test_detect_available_configs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from can import detect_available_configs
1717

18-
from .config import IS_LINUX, IS_CI
18+
from .config import IS_LINUX, IS_CI, TEST_INTERFACE_SOCKETCAN
1919

2020

2121
class TestDetectAvailableConfigs(unittest.TestCase):
@@ -45,13 +45,13 @@ def test_content_socketcan(self):
4545
for config in configs:
4646
self.assertEqual(config['interface'], 'socketcan')
4747

48-
@unittest.skipUnless(IS_LINUX and IS_CI, "socketcan is only available on Linux")
48+
@unittest.skipUnless(TEST_INTERFACE_SOCKETCAN, "socketcan is not tested")
4949
def test_socketcan_on_ci_server(self):
5050
configs = detect_available_configs(interfaces='socketcan')
5151
self.assertGreaterEqual(len(configs), 1)
5252
self.assertIn('vcan0', [config['channel'] for config in configs])
5353

54-
# see TestSocketCanHelpers.test_find_available_interfaces()
54+
# see TestSocketCanHelpers.test_find_available_interfaces() too
5555

5656

5757
if __name__ == '__main__':

test/test_socketcan_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_find_available_interfaces(self):
3737
self.assertGreaterEqual(len(result), 0)
3838
for entry in result:
3939
self.assertRegexpMatches(entry, r"v?can\d+")
40-
if IS_CI:
40+
if TEST_INTERFACE_SOCKETCAN:
4141
self.assertGreaterEqual(len(result), 1)
4242
self.assertIn("vcan0", result)
4343

0 commit comments

Comments
 (0)