[PATCH bare-py 1/5] Fix test_int typo
Export this patch
---
bare/test_primitives.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bare/test_primitives.py b/bare/test_primitives.py
index 5315629..e18314e 100644
--- a/bare/test_primitives.py
@@ -81,7 +81,7 @@ class Test(TestCase):
assert result == number
@given(integers())
- def test_i64(self, number):
+ def test_int(self, number):
ast = BarePrimitive(TypeKind.INT)
packed = _pack_primitive(ast, number)
note(packed)
--
2.30.2
[PATCH bare-py 2/5] Remove unused import
Export this patch
---
bare/test_primitives.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bare/test_primitives.py b/bare/test_primitives.py
index e18314e..620b108 100644
--- a/bare/test_primitives.py
@@ -1,7 +1,7 @@
from math import isnan
from unittest import TestCase
-from hypothesis import given, note, seed
+from hypothesis import given, note
from hypothesis.strategies import integers, floats, booleans, binary, tuples, text
from bare import _pack_primitive, _unpack_primitive, BarePrimitive, TypeKind
--
2.30.2
[PATCH bare-py 3/5] Compare none using "is" (accomply to PEP8)
Export this patch
---
bare/test_primitives.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bare/test_primitives.py b/bare/test_primitives.py
index 620b108..b5f477e 100644
--- a/bare/test_primitives.py
@@ -155,4 +155,4 @@ class Test(TestCase):
ast = BarePrimitive(TypeKind.Void)
packed = _pack_primitive(ast, None)
result = _unpack_primitive(ast, packed, 0)[0]
- assert result == None
+ assert result is None
--
2.30.2
[PATCH bare-py 4/5] Fix unpack varint test comment
Export this patch
---
bare/test_varint.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bare/test_varint.py b/bare/test_varint.py
index d3cd034..61e71f9 100644
--- a/bare/test_varint.py
@@ -27,7 +27,7 @@ class Test(TestCase):
self.assertEqual(_unpack_varint(b'\0', 0, signed=True)[0], 0, 'int 0')
self.assertEqual(_unpack_varint(b'\x02', 0, signed=True)[0], 1, 'int 1')
self.assertEqual(_unpack_varint(b'\x01', 0, signed=True)[0], -1, 'int -1')
- self.assertEqual(_unpack_varint(b'\xf1\x14', 0, signed=True)[0], -1337, 'int -1')
+ self.assertEqual(_unpack_varint(b'\xf1\x14', 0, signed=True)[0], -1337, 'int -1337')
@given(integers(min_value=0))
def test_unsigned_varint(self, number):
--
2.30.2
[PATCH bare-py 5/5] Extend varint tests with data from RFC's appendix
Export this patch
---
bare/test_varint.py | 42 ++++++++++++++++++++++++++++++++++--------
1 file changed, 34 insertions(+), 8 deletions(-)
diff --git a/bare/test_varint.py b/bare/test_varint.py
index 61e71f9..c20d065 100644
--- a/bare/test_varint.py
@@ -8,25 +8,51 @@ from bare import _pack_varint, _unpack_varint
class Test(TestCase):
def test__pack_varint(self):
- self.assertEqual(_pack_varint(0), b'\0', 'uint zero')
- self.assertEqual(_pack_varint(0x7F), b'\x7f', 'uint 0x7f')
+ self.assertEqual(_pack_varint(0), b'\x00', 'uint 0')
+ self.assertEqual(_pack_varint(1), b'\x01', 'uint 1')
+ self.assertEqual(_pack_varint(126), b'\x7e', 'uint 126')
+ self.assertEqual(_pack_varint(127), b'\x7f', 'uint 127')
+ self.assertEqual(_pack_varint(128), b'\x80\x01', 'uint 128')
+ self.assertEqual(_pack_varint(129), b'\x81\x01', 'uint 129')
self.assertEqual(_pack_varint(0x1337), b'\xb7\x26', 'uint 0x1337')
+ self.assertEqual(_pack_varint(255), b'\xff\x01', 'uint 255')
- self.assertEqual(_pack_varint(42, signed=True), b'\x54', 'int 42')
- self.assertEqual(_pack_varint(0, signed=True), b'\0', 'int 0')
+ self.assertEqual(_pack_varint(0, signed=True), b'\x00', 'int 0')
self.assertEqual(_pack_varint(1, signed=True), b'\x02', 'int 1')
self.assertEqual(_pack_varint(-1, signed=True), b'\x01', 'int -1')
+ self.assertEqual(_pack_varint(42, signed=True), b'\x54', 'int 42')
+ self.assertEqual(_pack_varint(63, signed=True), b'\x7e', 'int 63')
+ self.assertEqual(_pack_varint(-63, signed=True), b'\x7d', 'int -63')
+ self.assertEqual(_pack_varint(64, signed=True), b'\x80\x01', 'int 64')
+ self.assertEqual(_pack_varint(-64, signed=True), b'\x7f', 'int -64')
+ self.assertEqual(_pack_varint(65, signed=True), b'\x82\x01', 'int 65')
+ self.assertEqual(_pack_varint(-65, signed=True), b'\x81\x01', 'int -65')
+ self.assertEqual(_pack_varint(255, signed=True), b'\xfe\x03', 'int 255')
+ self.assertEqual(_pack_varint(-255, signed=True), b'\xfd\x03', 'int -255')
self.assertEqual(_pack_varint(-1337, signed=True), b'\xf1\x14', 'int -1337')
def test__unpack_varint(self):
- self.assertEqual(_unpack_varint(b'\0', 0)[0], 0, 'uint zero')
- self.assertEqual(_unpack_varint(b'\x7f', 0)[0], 0x7f, 'uint 0x7f')
+ self.assertEqual(_unpack_varint(b'\x00', 0)[0], 0, 'uint 0')
+ self.assertEqual(_unpack_varint(b'\x01', 0)[0], 1, 'uint 1')
+ self.assertEqual(_unpack_varint(b'\x7e', 0)[0], 126, 'uint 126')
+ self.assertEqual(_unpack_varint(b'\x7f', 0)[0], 127, 'uint 127')
+ self.assertEqual(_unpack_varint(b'\x80\x01', 0)[0], 128, 'uint 128')
+ self.assertEqual(_unpack_varint(b'\x81\x01', 0)[0], 129, 'uint 129')
self.assertEqual(_unpack_varint(b'\xb7\x26', 0)[0], 0x1337, 'uint 0x1337')
+ self.assertEqual(_unpack_varint(b'\xff\x01', 0)[0], 255, 'uint 255')
- self.assertEqual(_unpack_varint(b'\x54', 0, signed=True)[0], 42, 'int 42')
- self.assertEqual(_unpack_varint(b'\0', 0, signed=True)[0], 0, 'int 0')
+ self.assertEqual(_unpack_varint(b'\x00', 0, signed=True)[0], 0, 'int 0')
self.assertEqual(_unpack_varint(b'\x02', 0, signed=True)[0], 1, 'int 1')
self.assertEqual(_unpack_varint(b'\x01', 0, signed=True)[0], -1, 'int -1')
+ self.assertEqual(_unpack_varint(b'\x54', 0, signed=True)[0], 42, 'int 42')
+ self.assertEqual(_unpack_varint(b'\x7e', 0, signed=True)[0], 63, 'int 63')
+ self.assertEqual(_unpack_varint(b'\x7d', 0, signed=True)[0], -63, 'int -63')
+ self.assertEqual(_unpack_varint(b'\x80\x01', 0, signed=True)[0], 64, 'int 64')
+ self.assertEqual(_unpack_varint(b'\x7f', 0, signed=True)[0], -64, 'int -64')
+ self.assertEqual(_unpack_varint(b'\x82\x01', 0, signed=True)[0], 65, 'int 65')
+ self.assertEqual(_unpack_varint(b'\x81\x01', 0, signed=True)[0], -65, 'int -65')
+ self.assertEqual(_unpack_varint(b'\xfe\x03', 0, signed=True)[0], 255, 'int 255')
+ self.assertEqual(_unpack_varint(b'\xfd\x03', 0, signed=True)[0], -255, 'int -255')
self.assertEqual(_unpack_varint(b'\xf1\x14', 0, signed=True)[0], -1337, 'int -1337')
@given(integers(min_value=0))
--
2.30.2
bare-py/patches/.build.yml: SUCCESS in 37s
[Fix test_int typo][0] from [Jiri Vlasak][1]
[0]: https://lists.sr.ht/~martijnbraam/public-inbox/patches/47245
[1]: mailto:jiri.hubacek@gmail.com
✓ #1105442 SUCCESS bare-py/patches/.build.yml https://builds.sr.ht/~martijnbraam/job/1105442