Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ PYX = $(wildcard mbedtls/*.pyx)
PYX += $(wildcard mbedtls/cipher/*.pyx)
PYX += $(wildcard mbedtls/pk/*.pyx)

LIBMBEDTLS = $(HOME)/lib/mbedtls-2.5.2

release:
cython $(PYX)
python setup.py build_ext

debug:
cython -a -X linetrace=True $(PYX)
CFLAGS='-DCYTHON_TRACE=1' python setup.py build_ext --inplace
CFLAGS='-DCYTHON_TRACE=1' python setup.py build_ext --inplace \
-L$(LIBMBEDTLS)/lib \
-I$(LIBMBEDTLS)/include

test:
nosetests -v --with-coverage --cover-package=mbedtls
pytest --cov mbedtls tests

html:
cd docs && make html
Expand Down
Empty file added mbedtls/__init__.py
Empty file.
Empty file added mbedtls/cipher/__init__.py
Empty file.
Empty file added mbedtls/pk/__init__.py
Empty file.
19 changes: 3 additions & 16 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# pylint: disable=missing-docstring

import random


Expand All @@ -10,28 +12,13 @@ def assert_canonical_repr(obj):
# pylint: disable=eval-used
newobj = eval(repr(obj), frame.f_globals, frame.f_locals)
except TypeError:
raise AssertionError("Cannot eval '%r'" % obj) from None
raise AssertionError("Cannot eval '%r'" % obj)
finally:
# explicitely delete the frame to avoid memory leaks, see also
# https://docs.python.org/3/library/inspect.html#the-interpreter-stack
del frame
assert isinstance(newobj, type(obj))
assert_canonical_repr.__test__ = False


def _rnd(length):
return bytes(random.randrange(0, 256) for _ in range(length))
_rnd.__test__ = False


class TestRnd:

@staticmethod
def test_key_length():
for length in range(1024 + 1, 8):
assert len(_rnd(length)) == length

@staticmethod
def test_values_fit_in_latin1():
k = _rnd(2048)
assert k.decode("latin1")
Loading