Skip to content

Commit 78e4834

Browse files
committed
general cleanup of the tests
1 parent 23d928e commit 78e4834

File tree

10 files changed

+61
-25
lines changed

10 files changed

+61
-25
lines changed

test/back2back_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
"""
5+
This module tests two virtual busses attached to each other.
6+
7+
Some tests are skipped when run on Travis CI because they are not
8+
reproducible, see #243 (https://github.com/hardbyte/python-can/issues/243).
9+
"""
10+
111
import os
212
import unittest
313
import time

test/data/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8

test/data/example_data.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# -*- coding: utf-8 -*-
1+
#!/usr/bin/env python
2+
# coding: utf-8
23

34
"""
45
This module contains some example data, like messages of different

test/listener_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
"""
5+
"""
6+
17
from time import sleep
28
import unittest
39
import random

test/logformats_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
14
"""
25
This test module test the separate reader/writer combinations of the can.io.*
36
modules by writing some messages to a temporary file and reading it again.
@@ -8,6 +11,8 @@
811
comments.
912
"""
1013

14+
from __future__ import print_function
15+
1116
import unittest
1217
import tempfile
1318
from time import sleep

test/network_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
14
from __future__ import print_function
25

36
import unittest

test/serial_test.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,17 @@
1-
# -*- coding: utf-8 -*-
1+
#!/usr/bin/env python
2+
# coding: utf-8
23

34
"""
4-
Name: serial_test
5-
Purpose: Testing the serial interface
5+
This module is testing the serial interface.
66
7-
Copyright: 2017 Boris Wenzlaff
8-
9-
This file is part of python-can <https://github.com/hardbyte/python-can/>.
10-
11-
python-can is free software: you can redistribute it and/or modify
12-
it under the terms of the GNU Lesser General Public License as published by
13-
the Free Software Foundation, either version 3 of the License, or
14-
any later version.
15-
16-
python-can is distributed in the hope that it will be useful,
17-
but WITHOUT ANY WARRANTY; without even the implied warranty of
18-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19-
GNU Lesser General Public License for more details.
20-
21-
You should have received a copy of the GNU Lesser General Public License
22-
along with python-can. If not, see <http://www.gnu.org/licenses/>.
7+
Copyright: 2017 Boris Wenzlaff
238
"""
249

2510
import unittest
11+
from mock import patch
12+
2613
import can
2714
from can.interfaces.serial.serial_can import SerialBus
28-
from mock import patch
2915

3016

3117
class SerialDummy:

test/simplecyclic_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
"""
5+
This module tests cyclic send tasks.
6+
7+
Some tests are skipped when run on Travis CI because they are not
8+
reproducible, see #243 (https://github.com/hardbyte/python-can/issues/243).
9+
"""
10+
111
import os
212
from time import sleep
313
import unittest

test/test_kvaser.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
"""
5+
"""
6+
27
import ctypes
38
import unittest
49
import time
510
import logging
6-
logging.basicConfig(level=logging.DEBUG)
11+
712
import can
813
from can.interfaces.kvaser import canlib
914
from can.interfaces.kvaser import constants

test/zero_dlc_test.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
"""
5+
"""
6+
17
from time import sleep
28
import unittest
39
import logging
10+
411
import can
512

613
logging.getLogger(__file__).setLevel(logging.DEBUG)
@@ -11,7 +18,8 @@ class ZeroDLCTest(unittest.TestCase):
1118
def test_recv_non_zero_dlc(self):
1219
bus_send = can.interface.Bus(bustype='virtual')
1320
bus_recv = can.interface.Bus(bustype='virtual')
14-
msg_send = can.Message(extended_id=False, arbitration_id=0x100, data=[0,1,2,3,4,5,6,7])
21+
data = [0, 1, 2, 3, 4, 5, 6, 7]
22+
msg_send = can.Message(extended_id=False, arbitration_id=0x100, data=data)
1523

1624
bus_send.send(msg_send)
1725
msg_recv = bus_recv.recv()
@@ -27,7 +35,6 @@ def test_recv_none(self):
2735
# Receiving nothing should evaluate msg_recv to False
2836
self.assertFalse(msg_recv)
2937

30-
3138
def test_recv_zero_dlc(self):
3239
bus_send = can.interface.Bus(bustype='virtual')
3340
bus_recv = can.interface.Bus(bustype='virtual')
@@ -39,5 +46,6 @@ def test_recv_zero_dlc(self):
3946
# Receiving a frame without data (dlc == 0) should evaluate msg_recv to True
4047
self.assertTrue(msg_recv)
4148

49+
4250
if __name__ == '__main__':
4351
unittest.main()

0 commit comments

Comments
 (0)