test: Cleanup tests and use relative imports

This commit is contained in:
2024-11-08 08:31:39 +01:00
parent dc5906288c
commit 276ea8dd72
26 changed files with 79 additions and 33 deletions

5
tests/common/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Init file for test group."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"

View File

@@ -6,7 +6,7 @@ __license__ = "GPLv2"
from os.path import dirname
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestConfigRscBugs(TestRevPiModIO):

View File

@@ -8,7 +8,7 @@ from os.path import dirname
from revpimodio2 import OUT, MEM, INP
from revpimodio2.device import Virtual, Base
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestDevicesModule(TestRevPiModIO):

View File

@@ -9,7 +9,7 @@ from os.path import join, dirname
from shutil import copyfile
import revpimodio2
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestInitModio(TestRevPiModIO):

View File

@@ -9,7 +9,7 @@ from os.path import join, dirname
from signal import SIGINT
from threading import Event
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestModioClassBasics(TestRevPiModIO):

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Init file for test group."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"

View File

@@ -4,10 +4,10 @@ __author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"
from os.path import join, dirname
from os.path import dirname
import revpimodio2
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestCompact(TestRevPiModIO):

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Init file for test group."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"

View File

@@ -8,8 +8,8 @@ from os.path import dirname, join
from time import sleep
import revpimodio2
from tests import TestRevPiModIO
from tests.helper import ExitThread
from .. import TestRevPiModIO
from ..helper import ExitThread
event_data = (None, None)

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Init file for test group."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"

View File

@@ -9,8 +9,8 @@ from threading import Event
from time import sleep
from revpimodio2 import RISING, FALLING
from tests import TestRevPiModIO
from tests.helper import ChangeThread
from .. import TestRevPiModIO
from ..helper import ChangeThread
event_data = (None, None)

View File

@@ -6,8 +6,8 @@ __license__ = "GPLv2"
from os.path import dirname
from tests import TestRevPiModIO
from tests.helper import ExitSignal
from .. import TestRevPiModIO
from ..helper import ExitSignal
class TestSignals(TestRevPiModIO):

5
tests/flat/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Init file for test group."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"

View File

@@ -7,7 +7,7 @@ __license__ = "GPLv2"
from os.path import dirname
import revpimodio2
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestFlat(TestRevPiModIO):

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Init file for test group."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"

View File

@@ -7,7 +7,7 @@ __license__ = "GPLv2"
from os.path import dirname
from revpimodio2 import OUT
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestIoFunctions(TestRevPiModIO):

View File

@@ -7,7 +7,7 @@ __license__ = "GPLv2"
from os.path import dirname
from revpimodio2.io import IntIOCounter
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestIos(TestRevPiModIO):

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Init file for test group."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"

View File

@@ -8,8 +8,8 @@ from os.path import dirname
from time import sleep
import revpimodio2
from tests import TestRevPiModIO
from tests.helper import ExitThread, ChangeThread
from .. import TestRevPiModIO
from ..helper import ExitThread, ChangeThread
event_data = (None, None)

View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Init file for test group."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"

View File

@@ -7,7 +7,7 @@ __license__ = "GPLv2"
from os.path import join, dirname
from revpimodio2.io import IntIOReplaceable
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestReplaceIO(TestRevPiModIO):
@@ -148,20 +148,16 @@ class TestReplaceIO(TestRevPiModIO):
def test_replace_io_file_fail(self):
with self.assertRaises(RuntimeError):
rpi = self.modio(replace_io_file=join(self.data_dir, "replace_io_fail.conf"))
self.modio(replace_io_file=join(self.data_dir, "replace_io_fail.conf"))
with self.assertRaises(RuntimeError):
rpi = self.modio(replace_io_file="no_file_nonono")
self.modio(replace_io_file="no_file_nonono")
with self.assertRaises(RuntimeError):
rpi = self.modio(replace_io_file=join(self.data_dir, "replace_io_failformat.conf"))
self.modio(replace_io_file=join(self.data_dir, "replace_io_failformat.conf"))
with self.assertRaises(ValueError):
rpi = self.modio(
replace_io_file=join(self.data_dir, "replace_io_faildefaultvalue_bool.conf")
)
self.modio(replace_io_file=join(self.data_dir, "replace_io_faildefaultvalue_bool.conf"))
with self.assertRaises(ValueError):
rpi = self.modio(
replace_io_file=join(self.data_dir, "replace_io_faildefaultvalue_int.conf")
)
self.modio(replace_io_file=join(self.data_dir, "replace_io_faildefaultvalue_int.conf"))
with self.assertRaises(ValueError):
rpi = self.modio(replace_io_file=join(self.data_dir, "replace_io_failbit_int.conf"))
self.modio(replace_io_file=join(self.data_dir, "replace_io_failbit_int.conf"))
with self.assertRaisesRegex(ValueError, r"defaultvalue to bytes"):
rpi = self.modio(replace_io_file=join(self.data_dir, "replace_io_bytes_fail.conf"))
self.modio(replace_io_file=join(self.data_dir, "replace_io_bytes_fail.conf"))

5
tests/revpi3/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Init file for test group."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"

View File

@@ -7,7 +7,7 @@ __license__ = "GPLv2"
from os.path import dirname
from revpimodio2 import BLUE
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestRevPiConnect(TestRevPiModIO):

View File

@@ -8,7 +8,7 @@ from os.path import dirname
from revpimodio2 import RED, GREEN, OFF, BLUE
from revpimodio2.io import IOBase, IntIO
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestRevPiCore(TestRevPiModIO):

5
tests/revpi4/__init__.py Normal file
View File

@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
"""Init file for test group."""
__author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"

View File

@@ -4,10 +4,10 @@ __author__ = "Sven Sager"
__copyright__ = "Copyright (C) 2024 Sven Sager"
__license__ = "GPLv2"
from os.path import join, dirname
from os.path import dirname
import revpimodio2
from tests import TestRevPiModIO
from .. import TestRevPiModIO
class TestRevPi4(TestRevPiModIO):