def pytest_generate_tests(metafunc): """Generate some `transformation` funcargs to test with""" if "transformation" in metafunc.funcargnames: matrix_transformation = MatrixTransformation() def assert__matrix_equal(*values): """Make sure we got the right matrix""" assert matrix_almost_equal(matrix_transformation, *values) matrix_transformation.assert__matrix_equal = assert__matrix_equal points = [ (0, 0, 0), (1, 0, 0), (0, 1, 0), (0, 0, 1), (1, 1, 1), (1, 2, 3), (-5, 80, 3.2), (4, 8.2, 0), ] metafunc.parametrize("transformation", [matrix_transformation] + [ TestPointTransformation(*p) for p in points], ids=['MatrixTransformation'] + points)
def assert__matrix_equal(self, *values): """Make sure we're getting the right point back""" matrix = MatrixTransformation() matrix.premultiply(values) assert sequences_almost_equal(self.point, matrix.transform_point(*self.original_point))