Skip to content

Commit e1806c9

Browse files
committed
add notes to tests
1 parent 033eaf9 commit e1806c9

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

bitarray/test_bitarray.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Copyright (c) 2008 - 2025, Ilan Schnell; All Rights Reserved
2+
# bitarray is published under the PSF license.
3+
#
4+
# Author: Ilan Schnell
15
"""
26
Tests for bitarray
37

bitarray/test_util.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Copyright (c) 2019 - 2025, Ilan Schnell; All Rights Reserved
2+
# bitarray is published under the PSF license.
3+
#
4+
# Author: Ilan Schnell
15
"""
26
Tests for bitarray.util module
37
"""
@@ -526,7 +530,7 @@ def test_file(self):
526530
finally:
527531
shutil.rmtree(tmpdir)
528532

529-
# ---------------------------------------------------------------------------
533+
# ----------------------------- strip() -----------------------------------
530534

531535
class StripTests(unittest.TestCase, Util):
532536

@@ -593,7 +597,7 @@ def test_one_set(self):
593597
self.assertEqual(strip(a, 'both'), bitarray('1'))
594598
self.assertEqual(len(a), n)
595599

596-
# ---------------------------------------------------------------------------
600+
# ----------------------------- count_n() ---------------------------------
597601

598602
class CountN_Tests(unittest.TestCase, Util):
599603

@@ -710,9 +714,10 @@ def test_primes(self):
710714
a = gen_primes(10_000)
711715
# there are 1229 primes below 10,000
712716
self.assertEqual(a.count(), 1229)
713-
n = count_n(a, 1_000) - 1
714-
# the thousandth prime number is 7919
715-
self.assertEqual(n, 7919)
717+
for n, p in [( 10, 29), # the 10th prime number is 29
718+
( 100, 541), # the 100th prime number is 541
719+
(1000, 7919)]: # the 1000th prime number is 7919
720+
self.assertEqual(count_n(a, n) - 1, p)
716721

717722
def test_large(self):
718723
for _ in range(100):
@@ -818,7 +823,7 @@ def test_misc(self):
818823
self.assertEqual(all(a ^ b), count_xor(a, b) == n)
819824
self.assertEqual(all(a ^ b), a == ~b)
820825

821-
# ---------------------------------------------------------------------------
826+
# --------------------------- any_and() -----------------------------------
822827

823828
class BitwiseAnyTests(unittest.TestCase, Util):
824829

@@ -901,7 +906,7 @@ def test_one(self):
901906
a[i] = 1
902907
self.assertEqual(b[i], any_and(a, b))
903908

904-
# ---------------------------------------------------------------------------
909+
# ---------------------------- subset() -----------------------------------
905910

906911
class SubsetTests(unittest.TestCase, Util):
907912

@@ -950,7 +955,7 @@ def test_random(self):
950955
a.setall(1)
951956
self.check(b, a, True)
952957

953-
# ---------------------------------------------------------------------------
958+
# ------------------------- correspond_all() ------------------------------
954959

955960
class CorrespondAllTests(unittest.TestCase):
956961

@@ -988,10 +993,10 @@ def test_random(self):
988993
self.assertEqual(res[1] + res[2], count_xor(a, b))
989994
self.assertEqual(sum(res), n)
990995

991-
# ---------------------------------------------------------------------------
996+
# ----------------------------- byteswap() --------------------------------
992997

993998
@skipIf(is_pypy)
994-
class ByteswapTests(unittest.TestCase):
999+
class ByteSwapTests(unittest.TestCase):
9951000

9961001
def test_basic_bytearray(self):
9971002
a = bytearray(b"ABCD")
@@ -1086,7 +1091,7 @@ def test_reverse_bitarray(self):
10861091
a.bytereverse()
10871092
self.assertEqual(a, b[::-1])
10881093

1089-
# ---------------------------------------------------------------------------
1094+
# ------------------------------ parity() ---------------------------------
10901095

10911096
class ParityTests(unittest.TestCase):
10921097

@@ -1119,7 +1124,7 @@ def test_wrong_args(self):
11191124
self.assertRaises(TypeError, parity)
11201125
self.assertRaises(TypeError, parity, bitarray("110"), 1)
11211126

1122-
# ---------------------------------------------------------------------------
1127+
# ---------------------------- sum_indices() ------------------------------
11231128

11241129
class SumIndicesUtil(unittest.TestCase):
11251130

@@ -2404,7 +2409,7 @@ def test_bitwise_inplace(self):
24042409
c <<= n
24052410
self.assertEqual(ba2int(c), i << n)
24062411

2407-
# ---------------------------------------------------------------------------
2412+
# ---------------------- serialize() deserialize() -----------------------
24082413

24092414
class SerializationTests(unittest.TestCase, Util):
24102415

0 commit comments

Comments
 (0)