Skip to content

Instantly share code, notes, and snippets.

@marksimpson82
marksimpson82 / gist:fdc8f6915a6256391138fdc70a0a9a0b
Last active August 2, 2020 02:19
Generate redirect URLs from wordpress -> jekyll
def main(input_file):
with open(input_file) as f:
lines = f.readlines()
# sample line:
# _posts/2012-11-11-the-fundamentals-of-automated-testing-use-factories.md:#permalink: /?p=726
output = []
for l in lines:
l = l[7:]
@test_case(Vector3D(0,1,0), Vector3D(0,1,0), 1.0).description("blah 1")
@test_case(Vector3D(0,1,0), Vector3D(0,-1,0), -1.0).description("blah 2")
@test_case(Vector3D(0,1,0), Vector3D(1,0,0), 0.0).description("blah 3")
def test_dot(self, vec1, vec2, expected_result):
dot = Vector3D.dot(vec1, vec2)
self.assertEquals(dot, expected_result)
@marksimpson82
marksimpson82 / ddt.py
Created May 15, 2012 18:08
Data driven python testing
@data(
TestData(vec1=Vector3D(0,1,0), vec2=Vector3D(0,1,0), expected_result = 1.0).with_description("Aligned"),
TestData(vec1=Vector3D(0,1,0), vec2=Vector3D(0,-1,0), expected_result = -1.0).with_description("Opposite"),
TestData(vec1=Vector3D(0,1,0), vec2=Vector3D(1,0,0), expected_result = 0.0).with_description(("Perpendicular"))
)
def test_dot(self, test_data):
vec1 = test_data.vec1
vec2 = test_data.vec2
dot = Vector3D.dot(vec1, vec2)