Page MenuHome

Add Vector tests for
Confirmed, NormalPublicTO DO


Blender has a tests file for the mathutils module.

Execute this from Blenders source code directory:

blender --background -noaudio --python source/tests/

This is a simple example of testing in Python and currently all tests pass,

BUT: We miss tests for mathutils.Vector


Possible tests..

  • Vector.project()
  • Vector.reflect()
  • Vector.angle()
  • Vector.angle_signed()
  • Vector.rotation_difference()

As well as testing for success, its useful to test that zero length vectors give correct exceptions with angle measurement and incomparable args fail properly.,

Vectors sized 4+ are now supported but not used by many functions which rely on 2d or 3d vectors only, so ensuring large vectors dont fail is important too.

This is more of a beginner testing task since you can use existing tests as a reference.

Note, for extra points, heres a crash that could have been found with testing.
rB06b6cd83459713ef5c00f705f6cdf1481ed24179 Vector.cross on vectors sized >4

Event Timeline

Campbell Barton (campbellbarton) raised the priority of this task from to 90.
Campbell Barton (campbellbarton) updated the task description. (Show Details)
Campbell Barton (campbellbarton) added a project: Restricted Project.
Campbell Barton (campbellbarton) edited a custom field.
Campbell Barton (campbellbarton) updated the task description. (Show Details)

@Patrice Bertrand (PatB), great, there was a crash in Vector.cross - details linked above, would be nice to make sure new tests would find a crash like this.

I created diff D433 with 20 something tests for Vector functions.

A few comments and questions:

  • I use the console to find out the expected results. I do not check whether the result is actually correct, it will just be "same as in 2.70".
  • Could easily add another 20 on these functions, if these are going in the right direction.
  • Question: should we inspect the actual BLI_math.c so as to determine relevant use cases, such as a special branch if vector is zero ?

@Patrice Bertrand (PatB) - thanks for the diff,

For each function we could try have 3 functions...

  • regular case
  • irregular/degenerate case
  • error case (in fact we could have more then one error case. but to begin with...)

However I wouldn't do this for all functions right now. maybe focus on say, 6 or so (the ones I proposed in the initial list), get this reviewed and approved, then do the others after.

Bastien Montagne (mont29) lowered the priority of this task from 90 to Normal.Apr 11 2014, 6:07 PM