Description: Migration of tests from nose to unittest
Author: Marcos Talau <talau@debian.org>
Bug-Debian: https://bugs.debian.org/1018331
Last-Update: 2022-09-12

Index: crccheck/setup.py
===================================================================
--- crccheck.orig/setup.py
+++ crccheck/setup.py
@@ -23,8 +23,6 @@ setup(
     url='https://sourceforge.net/projects/crccheck/',
     download_url='https://sourceforge.net/projects/crccheck/files/',
     install_requires=[],
-    tests_require=['nose', ],
-    test_suite='nose.collector',
     classifiers=[
         "Development Status :: 5 - Production/Stable",
         "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
Index: crccheck/tests/test_base.py
===================================================================
--- crccheck.orig/tests/test_base.py
+++ crccheck/tests/test_base.py
@@ -1,129 +1,116 @@
-import sys
-from nose.plugins.skip import SkipTest
-from nose.tools import raises
-
-from crccheck.base import CrccheckBase
-from crccheck.crc import ALLCRCCLASSES
-import random
-
-
-def randombytes(length):
-    return [random.randint(0, 255) for n in range(0, length)]
-
-
-@raises(NotImplementedError)
-def test_abstract_method():
-    """ For coverage """
-    ab = CrccheckBase()
-    ab.process(bytearray(10))
-
-
-def test_init():
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            value = random.randint(0, 4294967295)
-            assert CrcClass(value).value() == value
-
-
-def test_reset():
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            value = random.randint(0, 4294967295)
-            c = CrcClass()
-            c.reset(value)
-            assert c.value() == value
-
-
-def test_final():
-    """.final() should not change internal value"""
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            data = randombytes(16)
-            crc = CrcClass()
-            crc.process(data)
-            assert crc.final() == crc.final()
-
-
-def test_finalhex():
-    """.finalhex() should match .final()"""
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            data = randombytes(16)
-            crc = CrcClass()
-            crc.process(data)
-            assert crc.final() == int(crc.finalhex(), 16)
-
-
-def test_finalbytes_big():
-    """.finalbytes() should match .final()"""
-    if sys.version_info < (3, 3, 0):
-        raise SkipTest
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            data = randombytes(16)
-            crc = CrcClass()
-            crc.process(data)
-            assert crc.final() == int.from_bytes(crc.finalbytes('big'), 'big')
-
-
-def test_finalbytes_little():
-    """.finalbytes() should match .final()"""
-    if sys.version_info < (3, 3, 0):
-        raise SkipTest
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            data = randombytes(16)
-            crc = CrcClass()
-            crc.process(data)
-            assert crc.final() == int.from_bytes(crc.finalbytes('little'), 'little')
-
-
-def test_calc():
-    """.calc() must be identical to .process() + .final()"""
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            data = randombytes(16)
-            crc = CrcClass()
-            crc.process(data)
-            assert CrcClass.calc(data) == crc.final()
-
-
-def test_calchex_big():
-    """.calchex() must be identical to .process() + .finalhex()"""
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            data = randombytes(16)
-            crc = CrcClass()
-            crc.process(data)
-            assert CrcClass.calchex(data, byteorder='big') == crc.finalhex('big')
-
-
-def test_calchex_little():
-    """.calchex() must be identical to .process() + .finalhex()"""
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            data = randombytes(16)
-            crc = CrcClass()
-            crc.process(data)
-            assert CrcClass.calchex(data, byteorder='little') == crc.finalhex('little')
-
-
-def test_calcbytes_big():
-    """.calcbytes() must be identical to .process() + .finalbytes()"""
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            data = randombytes(16)
-            crc = CrcClass()
-            crc.process(data)
-            assert CrcClass.calcbytes(data, byteorder='big') == crc.finalbytes('big')
-
-
-def test_calcbytes_little():
-    """.calcbytes() must be identical to .process() + .finalbytes()"""
-    for CrcClass in ALLCRCCLASSES:
-        for n in range(0, 16):
-            data = randombytes(16)
-            crc = CrcClass()
-            crc.process(data)
-            assert CrcClass.calcbytes(data, byteorder='little') == crc.finalbytes('little')
-
+import unittest
+import sys
+
+from crccheck.base import CrccheckBase
+from crccheck.crc import ALLCRCCLASSES
+import random
+
+def randombytes(length):
+    return [random.randint(0, 255) for n in range(0, length)]
+
+class TestBase(unittest.TestCase):
+
+    def test_abstract_method(self):
+        """ For coverage """
+        with self.assertRaises(NotImplementedError):
+            ab = CrccheckBase()
+            ab.process(bytearray(10))
+
+    def test_init(self):
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                value = random.randint(0, 4294967295)
+                assert CrcClass(value).value() == value
+
+    def test_reset(self):
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                value = random.randint(0, 4294967295)
+                c = CrcClass()
+                c.reset(value)
+                assert c.value() == value
+
+    def test_final(self):
+        """.final() should not change internal value"""
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                data = randombytes(16)
+                crc = CrcClass()
+                crc.process(data)
+                assert crc.final() == crc.final()
+
+    def test_finalhex(self):
+        """.finalhex() should match .final()"""
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                data = randombytes(16)
+                crc = CrcClass()
+                crc.process(data)
+                assert crc.final() == int(crc.finalhex(), 16)
+
+    def test_finalbytes_big(self):
+        """.finalbytes() should match .final()"""
+        if sys.version_info < (3, 3, 0):
+            raise self.skipTest("")
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                data = randombytes(16)
+                crc = CrcClass()
+                crc.process(data)
+                assert crc.final() == int.from_bytes(crc.finalbytes('big'), 'big')
+
+    def test_finalbytes_little(self):
+        """.finalbytes() should match .final()"""
+        if sys.version_info < (3, 3, 0):
+            raise self.skipTest("")
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                data = randombytes(16)
+                crc = CrcClass()
+                crc.process(data)
+                assert crc.final() == int.from_bytes(crc.finalbytes('little'), 'little')
+
+    def test_calc(self):
+        """.calc() must be identical to .process() + .final()"""
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                data = randombytes(16)
+                crc = CrcClass()
+                crc.process(data)
+                assert CrcClass.calc(data) == crc.final()
+
+    def test_calchex_big(self):
+        """.calchex() must be identical to .process() + .finalhex()"""
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                data = randombytes(16)
+                crc = CrcClass()
+                crc.process(data)
+                assert CrcClass.calchex(data, byteorder='big') == crc.finalhex('big')
+
+    def test_calchex_little(self):
+        """.calchex() must be identical to .process() + .finalhex()"""
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                data = randombytes(16)
+                crc = CrcClass()
+                crc.process(data)
+                assert CrcClass.calchex(data, byteorder='little') == crc.finalhex('little')
+
+    def test_calcbytes_big(self):
+        """.calcbytes() must be identical to .process() + .finalbytes()"""
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                data = randombytes(16)
+                crc = CrcClass()
+                crc.process(data)
+                assert CrcClass.calcbytes(data, byteorder='big') == crc.finalbytes('big')
+
+    def test_calcbytes_little(self):
+        """.calcbytes() must be identical to .process() + .finalbytes()"""
+        for CrcClass in ALLCRCCLASSES:
+            for n in range(0, 16):
+                data = randombytes(16)
+                crc = CrcClass()
+                crc.process(data)
+                assert CrcClass.calcbytes(data, byteorder='little') == crc.finalbytes('little')
Index: crccheck/tests/test_checksum.py
===================================================================
--- crccheck.orig/tests/test_checksum.py
+++ crccheck/tests/test_checksum.py
@@ -1,142 +1,128 @@
-""" Unit tests for checksum module.
-
-  License::
-  
-    Copyright (C) 2015-2016 by Martin Scharrer <martin@scharrer-online.de>
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-"""
-import sys
-from nose.plugins.skip import SkipTest
-from nose.tools import raises
-import random
-from crccheck import checksum
-from crccheck.checksum import ALLCHECKSUMCLASSES, Checksum32, Checksum, ChecksumXor
-from crccheck.base import CrccheckError
-
-
-def randombytes(length):
-    return [random.randint(0, 255) for n in range(0, length)]
-
-
-def test_allchecksums_bigendian():
-    def selftest_bigendian(cls):
-        return cls.selftest(byteorder='big')
-
-    for checksumclass in ALLCHECKSUMCLASSES:
-        yield selftest_bigendian, checksumclass
-
-
-def test_allchecksums_littleendian():
-    def selftest_littleendian(cls):
-        return cls.selftest(byteorder='little')
-
-    for checksumclass in ALLCHECKSUMCLASSES:
-        yield selftest_littleendian, checksumclass
-
-
-# noinspection PyProtectedMember
-@raises(CrccheckError)
-def test_allchecksums_fail():
-    checksumclass = ALLCHECKSUMCLASSES[0]
-    checksumclass.selftest(checksumclass._check_data, ~checksumclass._check_result)
-
-
-def test_generator():
-    Checksum32.calc((n for n in range(0, 255)))
-
-
-def test_list1():
-    Checksum32.calc([n for n in range(0, 255)])
-
-
-def test_list2():
-    Checksum32.calc([n for n in range(0, 255)], 1)
-
-
-def test_bytearray1():
-    Checksum32.calc(bytearray.fromhex("12345678909876543210"))
-
-
-def test_bytes():
-    if sys.version_info < (3, 3, 0):
-        raise SkipTest
-    Checksum32.calc(bytes.fromhex("12345678909876543210"))
-
-
-def test_string1():
-    if sys.version_info < (3, 3, 0):
-        raise SkipTest
-    Checksum32.calc(b"Teststring")
-
-
-def test_string3():
-    if sys.version_info < (3, 3, 0):
-        raise SkipTest
-    Checksum32.calc("Teststring".encode(), )
-
-
-def test_general_checksum_valid_width():
-    """ Checksum()
-
-        Should allow for any positive width
-        which is a multiple of 8.
-    """
-    for n in range(8, 129, 8):
-        Checksum(n)
-
-
-def test_general_checksum_invalid_width():
-    for n in (0, 1, 7, 9, 33):
-        try:
-            Checksum(n)
-        except ValueError:
-            pass
-        else:
-            raise Exception
-
-
-def test_general_checksum_ident():
-    data = randombytes(1024)
-    assert checksum.Checksum32.calc(data) == checksum.Checksum(32).process(data).final()
-    assert checksum.Checksum16.calc(data) == checksum.Checksum(16).process(data).final()
-    assert checksum.Checksum8.calc(data) == checksum.Checksum(8).process(data).final()
-
-
-def test_general_checksumxor_valid_width():
-    """ Checksum()
-
-        Should allow for any positive width
-        which is a multiple of 8.
-    """
-    for n in range(8, 129, 8):
-        ChecksumXor(n)
-
-
-def test_general_checksumxor_invalid_width():
-    for n in (0, 1, 7, 9, 33):
-        try:
-            ChecksumXor(n)
-        except ValueError:
-            pass
-        else:
-            raise Exception
-
-
-def test_general_checksumxor_ident():
-    data = randombytes(1024)
-    assert checksum.ChecksumXor32.calc(data) == checksum.ChecksumXor(32).process(data).final()
-    assert checksum.ChecksumXor16.calc(data) == checksum.ChecksumXor(16).process(data).final()
-    assert checksum.ChecksumXor8.calc(data) == checksum.ChecksumXor(8).process(data).final()
+""" Unit tests for checksum module.
+
+  License::
+
+    Copyright (C) 2015-2016 by Martin Scharrer <martin@scharrer-online.de>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+"""
+import unittest
+import sys
+import random
+from crccheck import checksum
+from crccheck.checksum import ALLCHECKSUMCLASSES, Checksum32, Checksum, ChecksumXor
+from crccheck.base import CrccheckError
+
+def randombytes(length):
+    return [random.randint(0, 255) for n in range(0, length)]
+
+class TestChecksum(unittest.TestCase):
+
+    def test_allchecksums_bigendian(self):
+        def selftest_bigendian(cls):
+            return cls.selftest(byteorder='big')
+
+        for checksumclass in ALLCHECKSUMCLASSES:
+            with self.subTest(checksumclass=checksumclass):
+                selftest_bigendian(checksumclass)
+
+    def test_allchecksums_littleendian(self):
+        def selftest_littleendian(cls):
+            return cls.selftest(byteorder='little')
+
+        for checksumclass in ALLCHECKSUMCLASSES:
+            with self.subTest(checksumclass=checksumclass):
+                selftest_littleendian(checksumclass)
+
+    # noinspection PyProtectedMember
+    def test_allchecksums_fail(self):
+        with self.assertRaises(CrccheckError):
+            checksumclass = ALLCHECKSUMCLASSES[0]
+            checksumclass.selftest(checksumclass._check_data, ~checksumclass._check_result)
+
+    def test_generator(self):
+        Checksum32.calc((n for n in range(0, 255)))
+
+    def test_list1(self):
+        Checksum32.calc([n for n in range(0, 255)])
+
+    def test_list2(self):
+        Checksum32.calc([n for n in range(0, 255)], 1)
+
+    def test_bytearray1(self):
+        Checksum32.calc(bytearray.fromhex("12345678909876543210"))
+
+    def test_bytes(self):
+        if sys.version_info < (3, 3, 0):
+            raise self.skipTest("")
+        Checksum32.calc(bytes.fromhex("12345678909876543210"))
+
+    def test_string1(self):
+        if sys.version_info < (3, 3, 0):
+            raise self.skipTest("")
+        Checksum32.calc(b"Teststring")
+
+    def test_string3(self):
+        if sys.version_info < (3, 3, 0):
+            raise self.skipTest("")
+        Checksum32.calc("Teststring".encode(), )
+
+    def test_general_checksum_valid_width(self):
+        """ Checksum()
+
+            Should allow for any positive width
+            which is a multiple of 8.
+        """
+        for n in range(8, 129, 8):
+            Checksum(n)
+
+    def test_general_checksum_invalid_width(self):
+        for n in (0, 1, 7, 9, 33):
+            try:
+                Checksum(n)
+            except ValueError:
+                pass
+            else:
+                raise Exception
+
+    def test_general_checksum_ident(self):
+        data = randombytes(1024)
+        assert checksum.Checksum32.calc(data) == checksum.Checksum(32).process(data).final()
+        assert checksum.Checksum16.calc(data) == checksum.Checksum(16).process(data).final()
+        assert checksum.Checksum8.calc(data) == checksum.Checksum(8).process(data).final()
+
+    def test_general_checksumxor_valid_width(self):
+        """ Checksum()
+
+            Should allow for any positive width
+            which is a multiple of 8.
+        """
+        for n in range(8, 129, 8):
+            ChecksumXor(n)
+
+    def test_general_checksumxor_invalid_width(self):
+        for n in (0, 1, 7, 9, 33):
+            try:
+                ChecksumXor(n)
+            except ValueError:
+                pass
+            else:
+                raise Exception
+
+    def test_general_checksumxor_ident(self):
+        data = randombytes(1024)
+        assert checksum.ChecksumXor32.calc(data) == checksum.ChecksumXor(32).process(data).final()
+        assert checksum.ChecksumXor16.calc(data) == checksum.ChecksumXor(16).process(data).final()
+        assert checksum.ChecksumXor8.calc(data) == checksum.ChecksumXor(8).process(data).final()
Index: crccheck/tests/test_crc.py
===================================================================
--- crccheck.orig/tests/test_crc.py
+++ crccheck/tests/test_crc.py
@@ -1,236 +1,202 @@
-""" Unit tests for checksum module.
-
-  License::
-  
-    Copyright (C) 2015-2016 by Martin Scharrer <martin@scharrer-online.de>
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-"""
-import sys
-from nose.plugins.skip import SkipTest
-from nose.tools import raises
-from crccheck.base import CrccheckError
-from crccheck.crc import ALLCRCCLASSES, ALLCRCCLASSES_ALIASES, Crc32, Crc, find, identify
-import crccheck
-import random
-
-
-def test_allcrc():
-    """Test if expected 'check' result is calulated with standard test vector."""
-    for crcclass in ALLCRCCLASSES:
-        yield lambda x: x.selftest(), crcclass
-
-
-def test_allcrcfail():
-    """Test if 'check' result is not reached with different input."""
-    def fail(cls):
-        try:
-            cls.selftest(bytearray(b"wrongtestinput"), cls._check_result)
-        except CrccheckError:
-            # This is the correct response
-            pass
-        else:
-            raise Exception("Selftest passed with incorrect input!")
-    for crcclass in ALLCRCCLASSES:
-        yield fail, crcclass
-
-
-def test_generator():
-    Crc32.calc((n for n in range(0, 255)))
-
-
-def test_list1():
-    Crc32.calc([n for n in range(0, 255)])
-
-
-def test_list2():
-    Crc32.calc([n for n in range(0, 255)], 123)
-
-
-def test_bytearray():
-    Crc32.calc(bytearray.fromhex("12345678909876543210"))
-
-
-def test_bytes():
-    if sys.version_info < (3, 3, 0):
-        raise SkipTest
-    Crc32.calc(bytes.fromhex("12345678909876543210"))
-
-
-def test_string1():
-    if sys.version_info < (3, 3, 0):
-        raise SkipTest
-    Crc32.calc(b"Teststring")
-
-
-def test_string2():
-    if sys.version_info < (3, 3, 0):
-        raise SkipTest
-    Crc32.calc("Teststring".encode(), )
-
-
-def test_general_crc():
-    crc = Crc(32, 0x4C11DB7, 0xFFFFFFFF, True, True, 0x00000000, 0x340BC6D9)
-    crc.selftest()
-
-
-@raises(CrccheckError)
-def test_general_crc_fail():
-    crc = Crc(32, 0x4C11DB7, 0xFFFFFFFF, True, True, 0x00000000, ~0x340BC6D9)
-    crc.selftest()
-
-
-def test_backwards_compatible():
-    """Crc8Base was called Crc8, etc. Must still be equal CRCs"""
-    assert crccheck.crc.Crc8() == crccheck.crc.Crc8Base()
-    assert crccheck.crc.Crc16() == crccheck.crc.Crc16Base()
-    assert crccheck.crc.Crc32() == crccheck.crc.Crc32Base()
-
-
-def test_find32():
-    for cls in find(width=32):
-        assert cls._width == 32
-
-
-def test_find_unknown():
-    assert len(find(width=12345)) == 0
-
-
-def test_find_all():
-    assert find() == list(ALLCRCCLASSES)
-
-
-def test_find_some():
-    assert find(ALLCRCCLASSES[1:3]) == list(ALLCRCCLASSES[1:3])
-
-
-def test_find_width():
-    assert find(width=32) == list(cls for cls in ALLCRCCLASSES if cls._width == 32)
-
-
-def test_find_poly():
-    assert find(poly=0x04C11DB7) == list(cls for cls in ALLCRCCLASSES if cls._poly == 0x04C11DB7)
-
-
-def test_find_initvalue():
-    assert find(initvalue=0) == list(cls for cls in ALLCRCCLASSES if cls._initvalue == 0)
-
-
-def test_find_reflect_input():
-    assert find(reflect_input=True) == list(cls for cls in ALLCRCCLASSES if cls._reflect_input)
-
-
-def test_find_reflect_output():
-    assert find(reflect_output=False) == list(cls for cls in ALLCRCCLASSES if not cls._reflect_output)
-
-
-def test_find_xor_output():
-    assert find(xor_output=0) == list(cls for cls in ALLCRCCLASSES if cls._xor_output == 0)
-
-
-def test_find_check_result():
-    assert find(check_result=6) == list(cls for cls in ALLCRCCLASSES if cls._check_result == 6)
-
-
-def test_find_residue():
-    assert find(residue=0) == list(cls for cls in ALLCRCCLASSES if cls._residue == 0)
-
-
-def test_find_mixed():
-    assert find(ALLCRCCLASSES[0:20], width=8, residue=0, reflect_input=False, reflect_output=False) \
-           == list(cls for cls in ALLCRCCLASSES[0:20] if cls._width == 8 and cls._residue == 0
-                   and not cls._reflect_input and not cls._reflect_output)
-
-
-def test_identify_1():
-    data = bytes(random.randrange(256) for _ in range(10))
-    cls = crccheck.crc.Crc64GoIso
-    assert identify(data, cls.calc(data))() == cls()
-
-
-def test_identify_2():
-    data = bytes(random.randrange(256) for _ in range(10))
-    classes = [crccheck.crc.Crc64GoIso, crccheck.crc.Crc8, crccheck.crc.Crc32IsoHdlc]
-    cls = crccheck.crc.Crc32IsoHdlc
-    assert identify(data, cls.calc(data), classes=classes)() == cls()
-
-
-def test_identify_width():
-    data = bytes(random.randrange(256) for _ in range(10))
-    allcrc32 = [c for c in ALLCRCCLASSES if c._width == 32]
-    cls = random.choice(allcrc32)
-    assert identify(data, cls.calc(data), 32)() == cls()
-    assert identify(data, cls.calc(data), 32, allcrc32)() == cls()
-
-
-def test_identify_width_list():
-    data = bytes(random.randrange(256) for _ in range(10))
-    allcrc32 = [c for c in ALLCRCCLASSES if c._width == 32]
-    cls = random.choice(allcrc32)
-    result = identify(data, cls.calc(data), 32, one=False)
-    assert len(result) >= 1 and result[0]() == cls()
-    result = identify(data, cls.calc(data), 32, allcrc32, one=False)
-    assert len(result) >= 1 and result[0]() == cls()
-
-
-def test_identify_notexisting():
-    assert identify(b'Test', 0) is None
-    assert identify(b'Test', 0, 234) is None
-    assert identify(b'Test', 0, classes=[]) is None
-    assert identify(b'Test', 0, 235, classes=[]) is None
-    assert identify(b'Test', 0, one=False) == []
-    assert identify(b'Test', 0, 234, one=False) == []
-    assert identify(b'Test', 0, classes=[], one=False) == []
-    assert identify(b'Test', 0, 235, classes=[], one=False) == []
-
-
-def test_repr():
-    """Test if __repr__ does not cause errors"""
-    c = Crc(16, 0xDEAD, initvalue=0x00, reflect_input=False, reflect_output=False,
-             xor_output=0x00, check_result=None, residue=None)
-    r = repr(c)
-    c = Crc(16, 0xDEAD, initvalue=0x00, reflect_input=False, reflect_output=False,
-             xor_output=0x00, check_result=None, residue=0x00)
-    r = repr(c)
-    c = Crc(16, 0xDEAD, initvalue=0x00, reflect_input=False, reflect_output=False,
-             xor_output=0x00, check_result=0x00, residue=None)
-    r = repr(c)
-    c = Crc(16, 0xDEAD, initvalue=0x00, reflect_input=False, reflect_output=False,
-             xor_output=0x00, check_result=0x00, residue=0x00)
-    r = repr(c)
-
-
-def test_selftest_data():
-    c = Crc(21, 0xDEAD)
-    c.selftest(b'Test', 0x40be8)
-
-
-def test_crc_calc():
-    assert Crc(21, 0xDEAD).calc(b'Test') == 265192
-
-
-def test_crc_calchex():
-    assert Crc(21, 0xDEAD).calchex(b'Test') == '040be8'
-
-
-def test_crc_calcbytes_big():
-    assert Crc(21, 0xDEAD).calcbytes(b'Test', byteorder='big') == b'\x04\x0b\xe8'
-
-
-def test_crc_calcbytes_little():
-    assert Crc(21, 0xDEAD).calcbytes(b'Test', byteorder='little') == b'\xe8\x0b\x04'
-
-
-def test_aliases():
-    assert set(ALLCRCCLASSES).issubset(ALLCRCCLASSES_ALIASES)
+""" Unit tests for checksum module.
+
+  License::
+
+    Copyright (C) 2015-2016 by Martin Scharrer <martin@scharrer-online.de>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+"""
+import unittest
+import sys
+from crccheck.base import CrccheckError
+from crccheck.crc import ALLCRCCLASSES, ALLCRCCLASSES_ALIASES, Crc32, Crc, find, identify
+import crccheck
+import random
+
+class TestCrc(unittest.TestCase):
+
+    def test_allcrc(self):
+        """Test if expected 'check' result is calulated with standard test vector."""
+        for crcclass in ALLCRCCLASSES:
+            with self.subTest(crcclass=crcclass):
+                crcclass.selftest()
+
+    def test_allcrcfail(self):
+        """Test if 'check' result is not reached with different input."""
+        def fail(cls):
+            try:
+                cls.selftest(bytearray(b"wrongtestinput"), cls._check_result)
+            except CrccheckError:
+                # This is the correct response
+                pass
+            else:
+                raise Exception("Selftest passed with incorrect input!")
+        for crcclass in ALLCRCCLASSES:
+            with self.subTest(crcclass=crcclass):
+                fail(crcclass)
+
+    def test_generator(self):
+        Crc32.calc((n for n in range(0, 255)))
+
+    def test_list1(self):
+        Crc32.calc([n for n in range(0, 255)])
+
+    def test_list2(self):
+        Crc32.calc([n for n in range(0, 255)], 123)
+
+    def test_bytearray(self):
+        Crc32.calc(bytearray.fromhex("12345678909876543210"))
+
+    def test_bytes(self):
+        if sys.version_info < (3, 3, 0):
+            raise self.skipTest("")
+        Crc32.calc(bytes.fromhex("12345678909876543210"))
+
+    def test_string1(self):
+        if sys.version_info < (3, 3, 0):
+            raise self.skipTest("")
+        Crc32.calc(b"Teststring")
+
+    def test_string2(self):
+        if sys.version_info < (3, 3, 0):
+            raise self.skipTest("")
+        Crc32.calc("Teststring".encode(), )
+
+    def test_general_crc(self):
+        crc = Crc(32, 0x4C11DB7, 0xFFFFFFFF, True, True, 0x00000000, 0x340BC6D9)
+        crc.selftest()
+
+    def test_general_crc_fail(self):
+        with self.assertRaises(CrccheckError):
+            crc = Crc(32, 0x4C11DB7, 0xFFFFFFFF, True, True, 0x00000000, ~0x340BC6D9)
+            crc.selftest()
+
+    def test_backwards_compatible(self):
+        """Crc8Base was called Crc8, etc. Must still be equal CRCs"""
+        assert crccheck.crc.Crc8() == crccheck.crc.Crc8Base()
+        assert crccheck.crc.Crc16() == crccheck.crc.Crc16Base()
+        assert crccheck.crc.Crc32() == crccheck.crc.Crc32Base()
+
+    def test_find32(self):
+        for cls in find(width=32):
+            assert cls._width == 32
+
+    def test_find_unknown(self):
+        assert len(find(width=12345)) == 0
+
+    def test_find_all(self):
+        assert find() == list(ALLCRCCLASSES)
+
+    def test_find_some(self):
+        assert find(ALLCRCCLASSES[1:3]) == list(ALLCRCCLASSES[1:3])
+
+    def test_find_width(self):
+        assert find(width=32) == list(cls for cls in ALLCRCCLASSES if cls._width == 32)
+
+    def test_find_poly(self):
+        assert find(poly=0x04C11DB7) == list(cls for cls in ALLCRCCLASSES if cls._poly == 0x04C11DB7)
+
+    def test_find_initvalue(self):
+        assert find(initvalue=0) == list(cls for cls in ALLCRCCLASSES if cls._initvalue == 0)
+
+    def test_find_reflect_input(self):
+        assert find(reflect_input=True) == list(cls for cls in ALLCRCCLASSES if cls._reflect_input)
+
+    def test_find_reflect_output(self):
+        assert find(reflect_output=False) == list(cls for cls in ALLCRCCLASSES if not cls._reflect_output)
+
+    def test_find_xor_output(self):
+        assert find(xor_output=0) == list(cls for cls in ALLCRCCLASSES if cls._xor_output == 0)
+
+    def test_find_check_result(self):
+        assert find(check_result=6) == list(cls for cls in ALLCRCCLASSES if cls._check_result == 6)
+
+    def test_find_residue(self):
+        assert find(residue=0) == list(cls for cls in ALLCRCCLASSES if cls._residue == 0)
+
+    def test_find_mixed(self):
+        assert find(ALLCRCCLASSES[0:20], width=8, residue=0, reflect_input=False, reflect_output=False) \
+            == list(cls for cls in ALLCRCCLASSES[0:20] if cls._width == 8 and cls._residue == 0
+                    and not cls._reflect_input and not cls._reflect_output)
+
+    def test_identify_1(self):
+        data = bytes(random.randrange(256) for _ in range(10))
+        cls = crccheck.crc.Crc64GoIso
+        assert identify(data, cls.calc(data))() == cls()
+
+    def test_identify_2(self):
+        data = bytes(random.randrange(256) for _ in range(10))
+        classes = [crccheck.crc.Crc64GoIso, crccheck.crc.Crc8, crccheck.crc.Crc32IsoHdlc]
+        cls = crccheck.crc.Crc32IsoHdlc
+        assert identify(data, cls.calc(data), classes=classes)() == cls()
+
+    def test_identify_width(self):
+        data = bytes(random.randrange(256) for _ in range(10))
+        allcrc32 = [c for c in ALLCRCCLASSES if c._width == 32]
+        cls = random.choice(allcrc32)
+        assert identify(data, cls.calc(data), 32)() == cls()
+        assert identify(data, cls.calc(data), 32, allcrc32)() == cls()
+
+    def test_identify_width_list(self):
+        data = bytes(random.randrange(256) for _ in range(10))
+        allcrc32 = [c for c in ALLCRCCLASSES if c._width == 32]
+        cls = random.choice(allcrc32)
+        result = identify(data, cls.calc(data), 32, one=False)
+        assert len(result) >= 1 and result[0]() == cls()
+        result = identify(data, cls.calc(data), 32, allcrc32, one=False)
+        assert len(result) >= 1 and result[0]() == cls()
+
+    def test_identify_notexisting(self):
+        assert identify(b'Test', 0) is None
+        assert identify(b'Test', 0, 234) is None
+        assert identify(b'Test', 0, classes=[]) is None
+        assert identify(b'Test', 0, 235, classes=[]) is None
+        assert identify(b'Test', 0, one=False) == []
+        assert identify(b'Test', 0, 234, one=False) == []
+        assert identify(b'Test', 0, classes=[], one=False) == []
+        assert identify(b'Test', 0, 235, classes=[], one=False) == []
+
+    def test_repr(self):
+        """Test if __repr__ does not cause errors"""
+        c = Crc(16, 0xDEAD, initvalue=0x00, reflect_input=False, reflect_output=False,
+                xor_output=0x00, check_result=None, residue=None)
+        r = repr(c)
+        c = Crc(16, 0xDEAD, initvalue=0x00, reflect_input=False, reflect_output=False,
+                xor_output=0x00, check_result=None, residue=0x00)
+        r = repr(c)
+        c = Crc(16, 0xDEAD, initvalue=0x00, reflect_input=False, reflect_output=False,
+                xor_output=0x00, check_result=0x00, residue=None)
+        r = repr(c)
+        c = Crc(16, 0xDEAD, initvalue=0x00, reflect_input=False, reflect_output=False,
+                xor_output=0x00, check_result=0x00, residue=0x00)
+        r = repr(c)
+
+    def test_selftest_data(self):
+        c = Crc(21, 0xDEAD)
+        c.selftest(b'Test', 0x40be8)
+
+    def test_crc_calc(self):
+        assert Crc(21, 0xDEAD).calc(b'Test') == 265192
+
+    def test_crc_calchex(self):
+        assert Crc(21, 0xDEAD).calchex(b'Test') == '040be8'
+
+    def test_crc_calcbytes_big(self):
+        assert Crc(21, 0xDEAD).calcbytes(b'Test', byteorder='big') == b'\x04\x0b\xe8'
+
+    def test_crc_calcbytes_little(self):
+        assert Crc(21, 0xDEAD).calcbytes(b'Test', byteorder='little') == b'\xe8\x0b\x04'
+
+    def test_aliases(self):
+        assert set(ALLCRCCLASSES).issubset(ALLCRCCLASSES_ALIASES)
Index: crccheck/tests/test_reflectbitorder.py
===================================================================
--- crccheck.orig/tests/test_reflectbitorder.py
+++ crccheck/tests/test_reflectbitorder.py
@@ -1,47 +1,42 @@
-from crccheck.base import reflectbitorder
-
-
-def test_1():
-    assert reflectbitorder(8, 0x80) == 0x01
-
-
-def test_2():
-    assert reflectbitorder(16, 0x8000) == 0x0001
-
-
-def test_3():
-    assert reflectbitorder(8, 0x81) == 0x81
-
-
-def test_4():
-    assert reflectbitorder(80, (1 << 79)) == 0x01
-
-
-def test_5():
-    assert reflectbitorder(65, 0x1) == (1 << 64)
-
-
-def test_6():
-    assert reflectbitorder(3, 0b110) == 0b011
-
-
-def test_7():
-    assert reflectbitorder(3, 0b110) == 0b011
-
-
-def test_8():
-    assert reflectbitorder(0, 0) == 0
-
-
-def expect(w, v, e):
-    assert reflectbitorder(w, v) == e
-
-
-def test_random():
-    import random
-    random.seed()
-    for width in range(1, 125):
-        randombitstr = "".join([str(random.randint(0, 1)) for m in range(0, width)])
-        value = int(randombitstr, 2)
-        expectedresult = int("".join(reversed(randombitstr)), 2)
-        yield expect, width, value, expectedresult
+import unittest
+
+from crccheck.base import reflectbitorder
+
+class TestReflectBitOrder(unittest.TestCase):
+
+    def test_1(self):
+        assert reflectbitorder(8, 0x80) == 0x01
+
+    def test_2(self):
+        assert reflectbitorder(16, 0x8000) == 0x0001
+
+    def test_3(self):
+        assert reflectbitorder(8, 0x81) == 0x81
+
+    def test_4(self):
+        assert reflectbitorder(80, (1 << 79)) == 0x01
+
+    def test_5(self):
+        assert reflectbitorder(65, 0x1) == (1 << 64)
+
+    def test_6(self):
+        assert reflectbitorder(3, 0b110) == 0b011
+
+    def test_7(self):
+        assert reflectbitorder(3, 0b110) == 0b011
+
+    def test_8(self):
+        assert reflectbitorder(0, 0) == 0
+
+    def expect(self, w, v, e):
+        assert reflectbitorder(w, v) == e
+
+    def test_random(self):
+        import random
+        random.seed()
+        for width in range(1, 125):
+            randombitstr = "".join([str(random.randint(0, 1)) for m in range(0, width)])
+            value = int(randombitstr, 2)
+            expectedresult = int("".join(reversed(randombitstr)), 2)
+            with self.subTest(width=width):
+                self.expect(width, value, expectedresult)
