Commit 70372b62 authored by steinbac's avatar steinbac

added video recordings

parent b1fc4e68
......@@ -2,6 +2,8 @@
This hacky hour is dedicated to unit testing in python with [py.test]( I'll start from a no-library solution and then will dive into it's capabilities using a small example code.
The video recordings of this session are available at .
## Target audience
If you know how to write a function in python and want to bring your coding to the next level, this talk is for you!
class geom_vector:
""" simple class to take a series of numbers and calculate a summary statistic from them, like a norm """
def __init__(self, _data=[]): = _data
self.method = max
def norm(self, method=None):
if not method:
method = self.method
def norm(self, method=max):
""" calculate the norm of our data, max is the default norm """
return method(
import pytest
from geom_vector import geom_vector
from geom_vector import geom_vector as gv
def test_creating_geom_vector():
def test_gv_construction():
gv = geom_vector()
sample = gv()
def test_add_payload():
def test_creating_geom_vector_with_data(test_data):
gv = geom_vector([1,2,3,4])
sample = gv([1,2,3,4])
def test_data():
def syn_data():
return [1,2,3,4]
def test_max_norm(test_data):
def test_payload_as_field(syn_data):
sample = gv(syn_data)
gv = geom_vector(test_data)
assert len( != 0
assert == [1,2,3,4]
assert gv.norm() == 4
def test_simple_norm(syn_data):
sample = gv(syn_data)
def test_sum_norm(test_data):
assert sample.norm() != 0
assert sample.norm() == 4
gv = geom_vector(test_data)
def test_custom_norm(syn_data):
assert gv.norm(sum) == 10
sample = gv(syn_data)
assert sample.norm(sum) != 0
assert sample.norm(sum) == 10
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment