Skip to content

Instantly share code, notes, and snippets.

Avatar

Martin Thoma MartinThoma

View GitHub Profile
View generate_from_type_annotations.py
from typing import Dict, Optional
from dataclasses import dataclass
from hypothesis import strategies as st
@dataclass
class PdfInfo:
path: str
is_errornous: bool
is_encrypted: bool
View test_datastructures.py
from hypothesis import given, strategies as st
from mpu.datastructures import Interval
@given(st.lists(st.integers(), min_size=4, max_size=4).map(sorted))
def test_interval_issubset(integer_list):
a, b, c, d = integer_list
assert Interval(b, c).issubset(Interval(a, d))
View test_two_way_functions.py
from hypothesis import given, strategies as s
from base64 import b64encode, b64decode
@given(s.binary())
def test_base64_encode_decode_together(data):
assert b64decode(b64encode(data)) == data
View test_string_verification.py
import hypothesis.strategies as s
from hypothesis import given
import mpu.string # Martins Python Utilities
@given(s.emails())
def test_is_email(email):
assert mpu.string.is_email(email), f"is_email({email}) returned False"
View test_factorize_property.py
# Third party
import hypothesis.strategies as s
from hypothesis import given
# First party
from factorize import factorize
@given(s.integers(min_value=-(10 ** 6), max_value=10 ** 6))
def test_factorize_multiplication_property(n):
View test_factorize_parametrize.py
# Third party modules
import pytest
# First party modules
from factorize import factorize
@pytest.mark.parametrize(
"n,expected",
[
View factorize.py
from typing import List
import math
def factorize(number: int) -> List[int]:
if number in [-1, 0, 1]:
return [number]
if number < 0:
return [-1] + factorize(-number)
factors = []
View pdftotext-extracted.txt
Test document
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed pulvinar nisi quis mauris egestas, maximus
congue tellus tempor. Quisque semper augue consectetur mattis imperdiet. Aliquam elementum, nibh
id scelerisque malesuada, arcu mauris ultricies tellus, non ultrices nulla lacus non erat. Curabitur in
diam a magna ornare finibus. Sed dapibus ipsum laoreet justo eleifend commodo. Nulla porttitor eros
odio, nec cursus mi sagittis eu. Duis metus arcu, auctor gravida interdum sed, congue a velit. Aliquam
malesuada posuere erat sit amet vehicula. Nunc vitae tempus orci. Nulla a elementum magna, vitae
scelerisque nisl. Phasellus gravida elit eu hendrerit tristique. Etiam rutrum ac ipsum vitae consequat.
Nam sit amet gravida arcu. Sed eget dictum lorem, eu consectetur sapien.
View .gitlab-ci.yml
image: python
stages:
- test
before_script:
- pip install pip --upgrade
- pip install -r dev-requirements.txt
after_script:
View .travis.yml
language: python
python:
- 3.6
- 3.7
- 3.8
install:
- pip install coveralls tox-travis
script:
- tox
after_success:
You can’t perform that action at this time.