mirror of
https://github.com/JoelBender/bacpypes
synced 2025-09-28 22:15:23 +08:00
convert tests from nose to pytest
This commit is contained in:
parent
3ed5224238
commit
0d8f237754
|
@ -5,8 +5,7 @@ ignore = E123,E221,E226,E302,E41,E701
|
||||||
max-line-length = 160
|
max-line-length = 160
|
||||||
max-complexity = 10
|
max-complexity = 10
|
||||||
|
|
||||||
[nosetests]
|
[pytest]
|
||||||
verbosity=3
|
|
||||||
detailed-errors=1
|
|
||||||
|
|
||||||
|
|
||||||
|
[aliases]
|
||||||
|
test=pytest
|
||||||
|
|
14
setup.py
14
setup.py
|
@ -28,8 +28,13 @@ requirements = [
|
||||||
# no external requirements
|
# no external requirements
|
||||||
]
|
]
|
||||||
|
|
||||||
|
setup_requirements = [
|
||||||
|
'pytest-runner',
|
||||||
|
]
|
||||||
|
|
||||||
test_requirements = [
|
test_requirements = [
|
||||||
'nose',
|
'pytest',
|
||||||
|
'bacpypes',
|
||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
@ -61,6 +66,9 @@ setup(
|
||||||
'Programming Language :: Python :: 3',
|
'Programming Language :: Python :: 3',
|
||||||
'Programming Language :: Python :: 3.4',
|
'Programming Language :: Python :: 3.4',
|
||||||
],
|
],
|
||||||
test_suite='nose.collector',
|
|
||||||
tests_require=test_requirements
|
setup_requires=setup_requirements,
|
||||||
|
|
||||||
|
test_suite='tests',
|
||||||
|
tests_require=test_requirements,
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,11 +7,12 @@ BACpypes Testing
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from . import utilities
|
from . import utilities
|
||||||
|
from . import state_machine
|
||||||
|
from . import time_machine
|
||||||
|
|
||||||
|
from . import test_comm
|
||||||
def setUpPackage():
|
# from . import test_objects
|
||||||
utilities.setUpPackage()
|
from . import test_pdu
|
||||||
|
from . import test_primitive_data
|
||||||
|
from . import test_utilities
|
||||||
def tearDownPackage():
|
from . import test_vlan
|
||||||
utilities.tearDownPackage()
|
|
||||||
|
|
14
tests/conftest.py
Normal file
14
tests/conftest.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
"""
|
||||||
|
Glue routines to simulate package setup and teardown.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from .utilities import setup_package, teardown_package
|
||||||
|
|
||||||
|
def pytest_configure(config):
|
||||||
|
setup_package()
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_unconfigure():
|
||||||
|
teardown_package()
|
|
@ -22,10 +22,6 @@ from bacpypes.task import FunctionTask as _FunctionTask
|
||||||
_debug = 0
|
_debug = 0
|
||||||
_log = ModuleLogger(globals())
|
_log = ModuleLogger(globals())
|
||||||
|
|
||||||
#
|
|
||||||
# Transitions
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
class Transition:
|
class Transition:
|
||||||
|
|
||||||
|
@ -65,11 +61,7 @@ class TimeoutTransition(Transition):
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
|
|
||||||
#
|
@bacpypes_debugging
|
||||||
# State
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
class State:
|
class State:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -297,14 +289,8 @@ class State:
|
||||||
hex(id(self)),
|
hex(id(self)),
|
||||||
)
|
)
|
||||||
|
|
||||||
bacpypes_debugging(State)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# StateMachine
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
class StateMachine:
|
class StateMachine:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -681,14 +667,8 @@ class StateMachine:
|
||||||
hex(id(self)),
|
hex(id(self)),
|
||||||
)
|
)
|
||||||
|
|
||||||
bacpypes_debugging(StateMachine)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# StateMachineGroup
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
class StateMachineGroup:
|
class StateMachineGroup:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -849,14 +829,8 @@ class StateMachineGroup:
|
||||||
at least one of them is in a 'fail' final state."""
|
at least one of them is in a 'fail' final state."""
|
||||||
if _debug: StateMachineGroup._debug("fail")
|
if _debug: StateMachineGroup._debug("fail")
|
||||||
|
|
||||||
bacpypes_debugging(StateMachineGroup)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# ClientStateMachine
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
class ClientStateMachine(Client, StateMachine):
|
class ClientStateMachine(Client, StateMachine):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -882,14 +856,8 @@ class ClientStateMachine(Client, StateMachine):
|
||||||
if _debug: ClientStateMachine._debug("confirmation %r", pdu)
|
if _debug: ClientStateMachine._debug("confirmation %r", pdu)
|
||||||
self.receive(pdu)
|
self.receive(pdu)
|
||||||
|
|
||||||
bacpypes_debugging(ClientStateMachine)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# ServerStateMachine
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
class ServerStateMachine(Server, StateMachine):
|
class ServerStateMachine(Server, StateMachine):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -914,5 +882,3 @@ class ServerStateMachine(Server, StateMachine):
|
||||||
def indication(self, pdu):
|
def indication(self, pdu):
|
||||||
if _debug: ServerStateMachine._debug("indication %r", pdu)
|
if _debug: ServerStateMachine._debug("indication %r", pdu)
|
||||||
self.receive(pdu)
|
self.receive(pdu)
|
||||||
|
|
||||||
bacpypes_debugging(ServerStateMachine)
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ _debug = 0
|
||||||
_log = ModuleLogger(globals())
|
_log = ModuleLogger(globals())
|
||||||
|
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
class TestSomething(unittest.TestCase):
|
class TestSomething(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -25,5 +26,3 @@ class TestSomething(unittest.TestCase):
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
if _debug: TestSomething._debug("tearDown")
|
if _debug: TestSomething._debug("tearDown")
|
||||||
|
|
||||||
bacpypes_debugging(TestSomething)
|
|
||||||
|
|
|
@ -2,19 +2,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Nose Test Module Template
|
Test Module Template
|
||||||
-------------------------
|
--------------------
|
||||||
|
|
||||||
This module is a template for creating MongoTree test cases. To create a
|
|
||||||
module of new tests, make a copy of this template and rename the
|
|
||||||
TestCaseTemplate and associated test_something functions.
|
|
||||||
|
|
||||||
In following with the nose testing methodology, setUpModule() will be called
|
|
||||||
before all of the tests in this module, setUpClass() will be called before
|
|
||||||
all of the tests in the class, and setUp() will be called before each test.
|
|
||||||
Similarly, tearDown() will be called after each test, tearDownClass() will be
|
|
||||||
called after all of the tests in the class, and tearDownModule() will be
|
|
||||||
called after all of the classes in the module.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -27,38 +16,45 @@ _debug = 0
|
||||||
_log = ModuleLogger(globals())
|
_log = ModuleLogger(globals())
|
||||||
|
|
||||||
|
|
||||||
def setUpModule():
|
@bacpypes_debugging
|
||||||
if _debug: setUpModule._debug("setUpModule")
|
def setup_module():
|
||||||
|
if _debug: setup_module._debug("setup_module")
|
||||||
bacpypes_debugging(setUpModule)
|
|
||||||
|
|
||||||
|
|
||||||
def tearDownModule():
|
@bacpypes_debugging
|
||||||
if _debug: tearDownModule._debug("tearDownModule")
|
def teardown_module():
|
||||||
|
if _debug: teardown_module._debug("teardown_module")
|
||||||
bacpypes_debugging(tearDownModule)
|
|
||||||
|
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
|
def setup_function(function):
|
||||||
|
if _debug: setup_function._debug("setup_function %r", function)
|
||||||
|
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
|
def teardown_function(function):
|
||||||
|
if _debug: teardown_function._debug("teardown_function %r", function)
|
||||||
|
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
class TestCaseTemplate(unittest.TestCase):
|
class TestCaseTemplate(unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setUpClass(cls):
|
def setup_class(cls):
|
||||||
if _debug: TestCaseTemplate._debug("setUpClass")
|
if _debug: TestCaseTemplate._debug("setup_class")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def tearDownClass(cls):
|
def teardown_class(cls):
|
||||||
if _debug: TestCaseTemplate._debug("tearDownClass")
|
if _debug: TestCaseTemplate._debug("teardown_class")
|
||||||
|
|
||||||
def setUp(self):
|
def setup_method(self, method):
|
||||||
if _debug: TestCaseTemplate._debug("setUp")
|
if _debug: TestCaseTemplate._debug("setup_module %r", method)
|
||||||
|
|
||||||
|
def teardown_method(self, method):
|
||||||
|
if _debug: TestCaseTemplate._debug("teardown_method %r", method)
|
||||||
|
|
||||||
def test_something(self):
|
def test_something(self):
|
||||||
if _debug: TestCaseTemplate._debug("test_something")
|
if _debug: TestCaseTemplate._debug("test_something")
|
||||||
|
|
||||||
def test_something_else(self):
|
def test_something_else(self):
|
||||||
if _debug: TestCaseTemplate._debug("test_something_else")
|
if _debug: TestCaseTemplate._debug("test_something_else")
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
if _debug: TestCaseTemplate._debug("tearDown")
|
|
||||||
|
|
||||||
bacpypes_debugging(TestCaseTemplate)
|
|
||||||
|
|
|
@ -5,4 +5,9 @@ Test BACpypes Comm Module
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from . import test_pci
|
from . import test_pci
|
||||||
|
from . import test_pdudata
|
||||||
|
from . import test_pdu
|
||||||
|
|
||||||
|
from . import test_client
|
||||||
|
from . import test_server
|
||||||
|
|
||||||
|
|
|
@ -16,38 +16,11 @@ _debug = 0
|
||||||
_log = ModuleLogger(globals())
|
_log = ModuleLogger(globals())
|
||||||
|
|
||||||
|
|
||||||
def setUpModule():
|
@bacpypes_debugging
|
||||||
if _debug: setUpModule._debug("setUpModule")
|
|
||||||
|
|
||||||
bacpypes_debugging(setUpModule)
|
|
||||||
|
|
||||||
|
|
||||||
def tearDownModule():
|
|
||||||
if _debug: tearDownModule._debug("tearDownModule")
|
|
||||||
|
|
||||||
bacpypes_debugging(tearDownModule)
|
|
||||||
|
|
||||||
|
|
||||||
class TestPCI(unittest.TestCase):
|
class TestPCI(unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
if _debug: TestPCI._debug("setUpClass")
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def tearDownClass(cls):
|
|
||||||
if _debug: TestPCI._debug("tearDownClass")
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
if _debug: TestPCI._debug("setUp")
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
if _debug: TestPCI._debug("tearDown")
|
|
||||||
|
|
||||||
def test_something(self):
|
def test_something(self):
|
||||||
if _debug: TestPCI._debug("test_something")
|
if _debug: TestPCI._debug("test_something")
|
||||||
|
|
||||||
def test_something_else(self):
|
def test_something_else(self):
|
||||||
if _debug: TestPCI._debug("test_something_else")
|
if _debug: TestPCI._debug("test_something_else")
|
||||||
|
|
||||||
bacpypes_debugging(TestPCI)
|
|
|
@ -16,38 +16,11 @@ _debug = 0
|
||||||
_log = ModuleLogger(globals())
|
_log = ModuleLogger(globals())
|
||||||
|
|
||||||
|
|
||||||
def setUpModule():
|
@bacpypes_debugging
|
||||||
if _debug: setUpModule._debug("setUpModule")
|
|
||||||
|
|
||||||
bacpypes_debugging(setUpModule)
|
|
||||||
|
|
||||||
|
|
||||||
def tearDownModule():
|
|
||||||
if _debug: tearDownModule._debug("tearDownModule")
|
|
||||||
|
|
||||||
bacpypes_debugging(tearDownModule)
|
|
||||||
|
|
||||||
|
|
||||||
class TestPDU(unittest.TestCase):
|
class TestPDU(unittest.TestCase):
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
if _debug: TestPDU._debug("setUpClass")
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def tearDownClass(cls):
|
|
||||||
if _debug: TestPDU._debug("tearDownClass")
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
if _debug: TestPDU._debug("setUp")
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
if _debug: TestPDU._debug("tearDown")
|
|
||||||
|
|
||||||
def test_something(self):
|
def test_something(self):
|
||||||
if _debug: TestPDU._debug("test_something")
|
if _debug: TestPDU._debug("test_something")
|
||||||
|
|
||||||
def test_something_else(self):
|
def test_something_else(self):
|
||||||
if _debug: TestPDU._debug("test_something_else")
|
if _debug: TestPDU._debug("test_something_else")
|
||||||
|
|
||||||
bacpypes_debugging(TestPDU)
|
|
||||||
|
|
|
@ -4,4 +4,19 @@
|
||||||
Test Primitive Data Module
|
Test Primitive Data Module
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from . import test_tag
|
||||||
|
|
||||||
|
from . import test_bit_string
|
||||||
|
from . import test_boolean
|
||||||
|
from . import test_character_string
|
||||||
|
from . import test_date
|
||||||
|
from . import test_double
|
||||||
|
from . import test_enumerated
|
||||||
from . import test_integer
|
from . import test_integer
|
||||||
|
from . import test_null
|
||||||
|
from . import test_object_identifier
|
||||||
|
from . import test_object_type
|
||||||
|
from . import test_octet_string
|
||||||
|
from . import test_real
|
||||||
|
from . import test_time
|
||||||
|
from . import test_unsigned
|
|
@ -27,7 +27,7 @@ class SampleBitString(BitString):
|
||||||
'b7': 7,
|
'b7': 7,
|
||||||
'b8': 8,
|
'b8': 8,
|
||||||
'b12': 12,
|
'b12': 12,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
|
@ -41,6 +41,7 @@ def bit_string_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def bit_string_encode(obj):
|
def bit_string_encode(obj):
|
||||||
"""Encode an BitString object into a tag."""
|
"""Encode an BitString object into a tag."""
|
||||||
|
@ -160,5 +161,4 @@ class TestBitString(unittest.TestCase):
|
||||||
bit_string_endec([0] * 2, '0600')
|
bit_string_endec([0] * 2, '0600')
|
||||||
bit_string_endec([1] * 2, '06c0')
|
bit_string_endec([1] * 2, '06c0')
|
||||||
bit_string_endec([0] * 10, '060000')
|
bit_string_endec([0] * 10, '060000')
|
||||||
bit_string_endec([1] * 10, '06ffc0')
|
bit_string_endec([1] * 10, '06ffc0')
|
||||||
|
|
|
@ -28,6 +28,7 @@ def boolean_tag(value):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def boolean_encode(obj):
|
def boolean_encode(obj):
|
||||||
"""Encode an Boolean object into a tag."""
|
"""Encode an Boolean object into a tag."""
|
||||||
|
@ -122,4 +123,4 @@ class TestBoolean(unittest.TestCase):
|
||||||
if _debug: TestBoolean._debug("test_boolean_endec")
|
if _debug: TestBoolean._debug("test_boolean_endec")
|
||||||
|
|
||||||
boolean_endec(False, False)
|
boolean_endec(False, False)
|
||||||
boolean_endec(True, True)
|
boolean_endec(True, True)
|
|
@ -32,6 +32,7 @@ def character_string_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def character_string_encode(obj):
|
def character_string_encode(obj):
|
||||||
"""Encode an CharacterString object into a tag."""
|
"""Encode an CharacterString object into a tag."""
|
||||||
|
@ -125,4 +126,4 @@ class TestCharacterString(unittest.TestCase):
|
||||||
obj = CharacterString(character_string_tag(''))
|
obj = CharacterString(character_string_tag(''))
|
||||||
|
|
||||||
character_string_endec("", '00')
|
character_string_endec("", '00')
|
||||||
character_string_endec("abc", '00616263')
|
character_string_endec("abc", '00616263')
|
|
@ -29,6 +29,7 @@ def date_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def date_encode(obj):
|
def date_encode(obj):
|
||||||
"""Encode an Date object into a tag."""
|
"""Encode an Date object into a tag."""
|
||||||
|
@ -174,4 +175,4 @@ class TestDate(unittest.TestCase):
|
||||||
def test_Wrong(self):
|
def test_Wrong(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
for each in self.notEnoughPreciseOrWrong:
|
for each in self.notEnoughPreciseOrWrong:
|
||||||
new_date = Date(each[0])
|
new_date = Date(each[0])
|
|
@ -31,6 +31,7 @@ def double_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def double_encode(obj):
|
def double_encode(obj):
|
||||||
"""Encode an Double object into a tag."""
|
"""Encode an Double object into a tag."""
|
||||||
|
@ -142,4 +143,4 @@ class TestDouble(unittest.TestCase):
|
||||||
double_endec(-inf, 'fff0000000000000')
|
double_endec(-inf, 'fff0000000000000')
|
||||||
|
|
||||||
nan = float('nan')
|
nan = float('nan')
|
||||||
double_endec(nan, '7ff8000000000000')
|
double_endec(nan, '7ff8000000000000')
|
|
@ -29,6 +29,7 @@ def enumerated_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def enumerated_encode(obj):
|
def enumerated_encode(obj):
|
||||||
"""Encode an Enumerated object into a tag."""
|
"""Encode an Enumerated object into a tag."""
|
||||||
|
@ -137,4 +138,4 @@ class TestEnumerated(unittest.TestCase):
|
||||||
enumerated_endec(8388608, '800000')
|
enumerated_endec(8388608, '800000')
|
||||||
|
|
||||||
enumerated_endec(2147483647, '7fffffff')
|
enumerated_endec(2147483647, '7fffffff')
|
||||||
enumerated_endec(2147483648, '80000000')
|
enumerated_endec(2147483648, '80000000')
|
|
@ -29,6 +29,7 @@ def integer_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def integer_encode(obj):
|
def integer_encode(obj):
|
||||||
"""Encode an Integer object into a tag."""
|
"""Encode an Integer object into a tag."""
|
||||||
|
@ -138,4 +139,4 @@ class TestInteger(unittest.TestCase):
|
||||||
integer_endec(-8388608, '800000')
|
integer_endec(-8388608, '800000')
|
||||||
|
|
||||||
integer_endec(2147483647, '7fffffff')
|
integer_endec(2147483647, '7fffffff')
|
||||||
integer_endec(-2147483648, '80000000')
|
integer_endec(-2147483648, '80000000')
|
|
@ -27,6 +27,7 @@ def null_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def null_encode(obj):
|
def null_encode(obj):
|
||||||
"""Encode an Integer object into a tag."""
|
"""Encode an Integer object into a tag."""
|
||||||
|
@ -103,4 +104,4 @@ class TestNull(unittest.TestCase):
|
||||||
def test_null_endec(self):
|
def test_null_endec(self):
|
||||||
if _debug: TestInteger._debug("test_null_endec")
|
if _debug: TestInteger._debug("test_null_endec")
|
||||||
|
|
||||||
null_endec((), '')
|
null_endec((), '')
|
|
@ -137,4 +137,4 @@ class TestObjectIdentifier(unittest.TestCase):
|
||||||
# test standard types
|
# test standard types
|
||||||
object_identifier_endec(('analogInput', 0), '00000000')
|
object_identifier_endec(('analogInput', 0), '00000000')
|
||||||
|
|
||||||
# test vendor types
|
# test vendor types
|
|
@ -39,6 +39,7 @@ def object_type_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def object_type_encode(obj):
|
def object_type_encode(obj):
|
||||||
"""Encode an ObjectType object into a tag."""
|
"""Encode an ObjectType object into a tag."""
|
||||||
|
@ -173,4 +174,4 @@ class TestObjectType(unittest.TestCase):
|
||||||
object_type_endec('analogOutput', '01')
|
object_type_endec('analogOutput', '01')
|
||||||
|
|
||||||
object_type_endec(127, '7f')
|
object_type_endec(127, '7f')
|
||||||
object_type_endec(128, '80')
|
object_type_endec(128, '80')
|
|
@ -30,6 +30,7 @@ def octet_string_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def octet_string_encode(obj):
|
def octet_string_encode(obj):
|
||||||
"""Encode an OctetString object into a tag."""
|
"""Encode an OctetString object into a tag."""
|
||||||
|
@ -125,4 +126,4 @@ class TestOctetString(unittest.TestCase):
|
||||||
octet_string_endec('01')
|
octet_string_endec('01')
|
||||||
octet_string_endec('0102')
|
octet_string_endec('0102')
|
||||||
octet_string_endec('010203')
|
octet_string_endec('010203')
|
||||||
octet_string_endec('01020304')
|
octet_string_endec('01020304')
|
|
@ -31,6 +31,7 @@ def real_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def real_encode(obj):
|
def real_encode(obj):
|
||||||
"""Encode an Real object into a tag."""
|
"""Encode an Real object into a tag."""
|
||||||
|
@ -143,4 +144,4 @@ class TestReal(unittest.TestCase):
|
||||||
real_endec(-inf, 'ff800000')
|
real_endec(-inf, 'ff800000')
|
||||||
|
|
||||||
nan = float('nan')
|
nan = float('nan')
|
||||||
real_endec(nan, '7fc00000')
|
real_endec(nan, '7fc00000')
|
|
@ -592,4 +592,4 @@ class TestTagList(unittest.TestCase):
|
||||||
|
|
||||||
taglist = TagList()
|
taglist = TagList()
|
||||||
taglist.decode(data)
|
taglist.decode(data)
|
||||||
assert taglist.tagList == [tag0, tag1, tag2]
|
assert taglist.tagList == [tag0, tag1, tag2]
|
|
@ -29,6 +29,7 @@ def time_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def time_encode(obj):
|
def time_encode(obj):
|
||||||
"""Encode an Time object into a tag."""
|
"""Encode an Time object into a tag."""
|
||||||
|
@ -140,4 +141,4 @@ class TestTime(unittest.TestCase):
|
||||||
time_endec((1, 0, 0, 0), '01000000')
|
time_endec((1, 0, 0, 0), '01000000')
|
||||||
time_endec((0, 2, 0, 0), '00020000')
|
time_endec((0, 2, 0, 0), '00020000')
|
||||||
time_endec((0, 0, 3, 0), '00000300')
|
time_endec((0, 0, 3, 0), '00000300')
|
||||||
time_endec((0, 0, 0, 4), '00000004')
|
time_endec((0, 0, 0, 4), '00000004')
|
|
@ -29,6 +29,7 @@ def unsigned_tag(x):
|
||||||
|
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def unsigned_encode(obj):
|
def unsigned_encode(obj):
|
||||||
"""Encode an Unsigned object into a tag."""
|
"""Encode an Unsigned object into a tag."""
|
||||||
|
@ -137,4 +138,4 @@ class TestUnsigned(unittest.TestCase):
|
||||||
unsigned_endec(8388608, '800000')
|
unsigned_endec(8388608, '800000')
|
||||||
|
|
||||||
unsigned_endec(2147483647, '7fffffff')
|
unsigned_endec(2147483647, '7fffffff')
|
||||||
unsigned_endec(2147483648, '80000000')
|
unsigned_endec(2147483648, '80000000')
|
|
@ -7,6 +7,10 @@ Test Utilities
|
||||||
This module tests the test utilities.
|
This module tests the test utilities.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from . import trapped_classes
|
||||||
|
|
||||||
from . import test_state_machine
|
from . import test_state_machine
|
||||||
|
from . import test_time_machine
|
||||||
|
|
||||||
from . import test_client_state_machine
|
from . import test_client_state_machine
|
||||||
from . import test_server_state_machine
|
from . import test_server_state_machine
|
|
@ -62,6 +62,7 @@ class TestState(unittest.TestCase):
|
||||||
def test_something_else(self):
|
def test_something_else(self):
|
||||||
if _debug: TestState._debug("test_something_else")
|
if _debug: TestState._debug("test_something_else")
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
class TestStateMachine(unittest.TestCase):
|
class TestStateMachine(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -21,14 +21,9 @@ _log = ModuleLogger(globals())
|
||||||
# reference to time machine
|
# reference to time machine
|
||||||
time_machine = None
|
time_machine = None
|
||||||
|
|
||||||
#
|
|
||||||
# setUpModule
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def setUpModule():
|
def setup_module(module):
|
||||||
if _debug: setUpModule._debug("setUpModule")
|
if _debug: setup_module._debug("setup_module %r", module)
|
||||||
global time_machine
|
global time_machine
|
||||||
|
|
||||||
# this is a singleton
|
# this is a singleton
|
||||||
|
@ -40,18 +35,14 @@ def setUpModule():
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def tearDownModule():
|
def teardown_module():
|
||||||
if _debug: tearDownModule._debug("tearDownModule")
|
if _debug: teardown_module._debug("teardown_module")
|
||||||
global time_machine
|
global time_machine
|
||||||
|
|
||||||
# all done
|
# all done
|
||||||
time_machine = None
|
time_machine = None
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# SampleOneShotTask
|
|
||||||
#
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
class SampleOneShotTask(OneShotTask):
|
class SampleOneShotTask(OneShotTask):
|
||||||
|
|
||||||
|
@ -66,10 +57,6 @@ class SampleOneShotTask(OneShotTask):
|
||||||
self.process_task_called += 1
|
self.process_task_called += 1
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# sample_task_function
|
|
||||||
#
|
|
||||||
|
|
||||||
# flag to make sure the function was called
|
# flag to make sure the function was called
|
||||||
sample_task_function_called = 0
|
sample_task_function_called = 0
|
||||||
|
|
||||||
|
@ -82,10 +69,6 @@ def sample_task_function(*args, **kwargs):
|
||||||
sample_task_function_called += 1
|
sample_task_function_called += 1
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# SampleRecurringTask
|
|
||||||
#
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
class SampleRecurringTask(RecurringTask):
|
class SampleRecurringTask(RecurringTask):
|
||||||
|
|
||||||
|
@ -203,4 +186,4 @@ class TestTimeMachine(unittest.TestCase):
|
||||||
# function called, no time has passed
|
# function called, no time has passed
|
||||||
assert ft1.process_task_called == 4
|
assert ft1.process_task_called == 4
|
||||||
assert ft2.process_task_called == 3
|
assert ft2.process_task_called == 3
|
||||||
assert time_machine.current_time == 5.0
|
assert time_machine.current_time == 5.0
|
|
@ -194,11 +194,8 @@ class TrappedStateMachine(StateMachine):
|
||||||
# must be identical objects
|
# must be identical objects
|
||||||
return pdu is transition_pdu
|
return pdu is transition_pdu
|
||||||
|
|
||||||
#
|
|
||||||
# TrappedClient
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
class TrappedClient(Client):
|
class TrappedClient(Client):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -231,14 +228,8 @@ class TrappedClient(Client):
|
||||||
# a reference for checking
|
# a reference for checking
|
||||||
self.confirmation_received = pdu
|
self.confirmation_received = pdu
|
||||||
|
|
||||||
bacpypes_debugging(TrappedClient)
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# TrappedServer
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
|
@bacpypes_debugging
|
||||||
class TrappedServer(Server):
|
class TrappedServer(Server):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -269,6 +260,4 @@ class TrappedServer(Server):
|
||||||
self.response_sent = pdu
|
self.response_sent = pdu
|
||||||
|
|
||||||
# continue with processing
|
# continue with processing
|
||||||
Server.response(self, pdu)
|
Server.response(self, pdu)
|
||||||
|
|
||||||
bacpypes_debugging(TrappedServer)
|
|
1
tests/test_vlan/__init__.py
Normal file
1
tests/test_vlan/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
# placeholder
|
|
@ -20,9 +20,6 @@ _log = ModuleLogger(globals())
|
||||||
# time machine
|
# time machine
|
||||||
time_machine = None
|
time_machine = None
|
||||||
|
|
||||||
#
|
|
||||||
# TimeMachine
|
|
||||||
#
|
|
||||||
|
|
||||||
# @bacpypes_debugging - implicit via metaclass
|
# @bacpypes_debugging - implicit via metaclass
|
||||||
class TimeMachine(_TaskManager):
|
class TimeMachine(_TaskManager):
|
||||||
|
@ -113,9 +110,6 @@ class TimeMachine(_TaskManager):
|
||||||
|
|
||||||
_TaskManager.process_task(self, task)
|
_TaskManager.process_task(self, task)
|
||||||
|
|
||||||
#
|
|
||||||
# reset_time_machine
|
|
||||||
#
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def reset_time_machine():
|
def reset_time_machine():
|
||||||
|
@ -133,9 +127,6 @@ def reset_time_machine():
|
||||||
time_machine.current_time = 0.0
|
time_machine.current_time = 0.0
|
||||||
time_machine.time_limit = None
|
time_machine.time_limit = None
|
||||||
|
|
||||||
#
|
|
||||||
# run_time_machine
|
|
||||||
#
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def run_time_machine(time_limit):
|
def run_time_machine(time_limit):
|
||||||
|
|
|
@ -26,37 +26,30 @@ BACPYPES_TEST_OPTION = ""
|
||||||
test_options = None
|
test_options = None
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# setUpPackage
|
|
||||||
#
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def setUpPackage():
|
def setup_package():
|
||||||
global test_options
|
global test_options
|
||||||
|
|
||||||
# create an argument parser
|
# create an argument parser
|
||||||
parser = ArgumentParser(description=__doc__)
|
parser = ArgumentParser(description=__doc__)
|
||||||
|
|
||||||
# add an option
|
# add an option
|
||||||
parser.add_argument('--option', help="this is an option",
|
parser.add_argument(
|
||||||
default=os.getenv("BACPYPES_TEST_OPTION") or BACPYPES_TEST_OPTION,
|
'--option', help="this is an option",
|
||||||
)
|
default=os.getenv("BACPYPES_TEST_OPTION") or BACPYPES_TEST_OPTION,
|
||||||
|
)
|
||||||
|
|
||||||
# get the debugging args and parse them
|
# get the debugging args and parse them
|
||||||
arg_str = os.getenv("BACPYPES_TEST") or BACPYPES_TEST
|
arg_str = os.getenv("BACPYPES_TEST") or BACPYPES_TEST
|
||||||
test_options = parser.parse_args(arg_str.split())
|
test_options = parser.parse_args(arg_str.split())
|
||||||
|
|
||||||
if _debug: setUpPackage._debug("setUpPackage")
|
if _debug: setup_package._debug("setup_package")
|
||||||
if _debug: setUpPackage._debug(" - test_options: %r", test_options)
|
if _debug: setup_package._debug(" - test_options: %r", test_options)
|
||||||
|
|
||||||
time_machine = TimeMachine()
|
time_machine = TimeMachine()
|
||||||
if _debug: setUpPackage._debug(" - time_machine: %r", time_machine)
|
if _debug: setup_package._debug(" - time_machine: %r", time_machine)
|
||||||
|
|
||||||
#
|
|
||||||
# tearDownPackage
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
@bacpypes_debugging
|
@bacpypes_debugging
|
||||||
def tearDownPackage():
|
def teardown_package():
|
||||||
if _debug: tearDownPackage._debug("tearDownPackage")
|
if _debug: teardown_package._debug("teardown_package")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user