Another pass to a working alpha

This commit is contained in:
Luke Murphy
2020-06-30 01:40:01 +02:00
parent b552a2d3e4
commit d5e54b936a
5 changed files with 36 additions and 8 deletions

View File

@ -1 +1,18 @@
# https://github.com/chrisdickinson/varint/blob/master/test.js
from math import floor, pow
from random import sample
from pyvarint import decode, encode, encoding_length
def test_fuzz_test():
ten_rand_ints = sample(range(100), 10)
for rand_int in ten_rand_ints:
encoded = encode(rand_int)
decoded = decode(encoded)
assert decoded == rand_int
def test_encoding_length():
for idx in range(0, 53):
number = floor(pow(2, idx))
assert len(encode(number)) == encoding_length(number)

View File

@ -2,9 +2,9 @@
def test_version_fails_gracefully(mocker):
target = 'pkg_resources.get_distribution'
target = "pkg_resources.get_distribution"
mocker.patch(target, side_effect=Exception())
from pyvarint.__init__ import __version__
assert __version__ == 'unknown'
assert __version__ == "unknown"