[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2469] branches/geodesic_domes/tests/ unittest3_sphere_problems.py: a test for analyzing the sphereparameters
Campbell Barton
ideasman42 at gmail.com
Mon Oct 17 18:23:46 CEST 2011
Noticed you're adding hard coded path to sys.path
sys.path.append("c:\\Users\\Peter\\25blender\\branches\\geodesic_domes")
While manipulating sys.path in a script isn't really great in the
first place, you can do it in a portable way:
To get the directory the script is in you can use this:
os.path.basename(__file__)
Though you could probably use a package and relative imports in this case.
On Mon, Oct 17, 2011 at 7:27 PM, Peter K.H. Gragert
<pkhgragert at gmail.com> wrote:
> Revision: 2469
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2469
> Author: pkhg
> Date: 2011-10-17 08:27:54 +0000 (Mon, 17 Oct 2011)
> Log Message:
> -----------
> a test for analyzing the sphereparameters
> meaning trying to understand the effects
>
> Added Paths:
> -----------
> branches/geodesic_domes/tests/unittest3_sphere_problems.py
>
> Added: branches/geodesic_domes/tests/unittest3_sphere_problems.py
> ===================================================================
> --- branches/geodesic_domes/tests/unittest3_sphere_problems.py (rev 0)
> +++ branches/geodesic_domes/tests/unittest3_sphere_problems.py 2011-10-17 08:27:54 UTC (rev 2469)
> @@ -0,0 +1,85 @@
> +##usable with SVN:2450
> +import bpy
> +import sys
> +#!!!!!!!!!!!!!!!!!!adjust this path to your settings
> +sys.path.append("c:\\Users\\Peter\\25blender\\branches\\geodesic_domes")
> +import unittest
> +import math
> +from mathutils import Vector #needed to check vertex.vector values
> +import geodesic_classes_259
> +import vefm_259
> +import forms_259
> +from forms_259 import sphere
> +print("\n--------------------start test SPHERE-------------\n\n")
> +def check_contains(cl,name , print_value = False, only_this = None):
> + dir_class = dir(cl)
> + tmp = None
> + for el in dir_class:
> + if el.startswith("_"):
> + pass
> + else:
> + if print_value == only_this:
> + tmp = getattr(cl,el)
> + print(name , " contains ==>",el," value = ", tmp)
> + else:
> + print(name , " contains ==>",el)
> + print("\ncheck_contains finished\n\n")
> + return tmp
> +
> +class geodesic_259_Test(unittest.TestCase):
> +
> + def setUp(self):
> + print("\n\n=============setup called================\n\n")
> + unittest.TestCase.setUp(self)
> + ## Superformula controls
> + um = 0 # Draw.Create(
> + un1 = 10.0 # Draw.Create(
> + un2 = 10.0 # Draw.Create(
> + un3 = 10.0 # Draw.Create(
> + ua = 1.0 # Draw.Create(
> + ub = 1.0 # Draw.Create(
> + vm = 4 # Draw.Create(
> + vn1 = 10.0 # Draw.Create(
> + vn2 = 10.0 # Draw.Create(
> + vn3 = 10.0 # Draw.Create(
> + va = 1.0 # Draw.Create(
> + vb = 1.0 # Draw.Create(
> + uact = 0 # Draw.Create(
> + vact = 0 # Draw.Create(
> + uturn = 0.0 # Draw.Create(
> + vturn = 0.0 # Draw.Create(
> + utwist = 0.232 # Draw.Create(
> + vtwist = 0.0 # Draw.Create(
> +
> + uresolution = 15 #number of lines N-S (u coordinate)
> + vresolution = 15 #number of lines O-W (v cordinate)
> + uscale = 10 #seams to be scaling from center in r direction
> + vscale = 0 #expand and shift get factor vscale
> + upart = 6.5 #gap?
> + vpart = 1 #defines gaps?!
> + uphase = vphase = 1
> + utwist = 0
> + vtwist = 0
> + xscale = 1 #scale in x direction
> + yscale = 1 #scale in z direction not y ?! the heigth so to say
> + sform = superformparam=[um,un1,un2,un3,ua,ub,vm,vn1,vn2,vn3,va,vb,uact,vact,uturn*math.pi,vturn*(math.pi),utwist,vtwist]
> +
> + self.sphere=forms_259.sphere(uresolution,vresolution,uscale,vscale,upart,vpart,uphase,vphase,utwist,vtwist,xscale,yscale,sform)
> +
> +
> + def test_content_modules(self):
> + sphere = self.sphere
> + try:
> + self.assertTrue(sphere != None)
> +
> + check_contains(dir(sphere), name="sphere", print_value = True)
> + finally:
> + vefm_259.vefm_add_object(sphere)
> + print("\ntest_content_modules done\n\n")
> +
> +
> +if __name__ == '__main__':
> +#if main use: exit=False unittest.main(exit=False)
> + suite = unittest.TestLoader().loadTestsFromTestCase(geodesic_259_Test)
> + unittest.TextTestRunner(verbosity=3).run(suite)
> +
>
> _______________________________________________
> Bf-extensions-cvs mailing list
> Bf-extensions-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-extensions-cvs
>
--
- Campbell
More information about the Bf-extensions-cvs
mailing list