Skip to content

Commit d9f6525

Browse files
committed
Ported common code to testing common
1 parent 569843a commit d9f6525

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

Packages/testing/common.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def test_values_setting(gm,attributes,good_values=[],bad_values=[]):
2+
if isinstance(attributes,str):
3+
attributes=[attributes,]
4+
for att in attributes:
5+
for val in good_values:
6+
setattr(gm,att,val)
7+
for val in bad_values:
8+
try:
9+
setattr(gm,att,val)
10+
success = True
11+
except:
12+
success = False
13+
else:
14+
if success:
15+
if hasattr(gm,"g_name"):
16+
nm = gm.g_name
17+
elif hasattr(gm,"s_name"):
18+
nm = gm.s_name
19+
else:
20+
nm=gm.p_name
21+
raise Exception,"Should not be able to set %s attribute '%s' to %s" % (nm,att,repr(val))
22+
sys.exit(1)

Packages/testing/regression.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def printDart(name, type, value, suff=""):
138138
printDart("ValidImage", "image/png", os.path.abspath(bestFilename), "File")
139139
return -1
140140

141+
141142
def main():
142143
if len(sys.argv) != 4:
143144
print "Error:"

testing/vcs/test_vcs_fillarea_basics_no_plot.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
2-
import vcs
3-
import numpy
4-
import cdtime
5-
6-
from vcs_test_common import *
1+
import numpy, cdtime, vcs
2+
from testing.common import test_values_setting
73

84
x=vcs.init()
95
x.drawlogooff()

testing/vcs/test_vcs_verify_boxfill_basics.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import vcs
2-
import numpy
3-
import cdtime
4-
5-
from vcs_test_common import *
1+
import numpy, cdtime, vcs
2+
from testing.common import test_values_setting
63

74
x=vcs.init()
85
x.drawlogooff()

testing/vcs/test_vcs_verify_proj_basics.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
2-
import vcs
3-
import numpy
4-
import cdtime
1+
import numpy, cdtime, vcs
2+
from testing.common import test_values_setting
53

64
from vcs_test_common import *
75

0 commit comments

Comments
 (0)