Commit e9aaf314 authored by Yori 'AGy' Fournier's avatar Yori 'AGy' Fournier
Browse files

not yet working version. Still making the tests of myTool.py, but I check the...

not yet working version. Still making the tests of myTool.py, but I check the relevance of the former tests and add some few corrections. Now it sounds ok.
parent c4bd8a5a
......@@ -124,7 +124,7 @@ from .test import myTest
from .test import test100
from .test import test200, test201, test202
from .test import test300, test301, test302, test303, test304, test305
from .test import test306, test307, test308, test309
from .test import test306, test307, test308, test309, test310
from .test import test400, test401, test402, test403
from .test import test600
......@@ -132,7 +132,7 @@ from .test import test600
testList = [test100,
test200, test201, test202,
test300, test301, test302, test303, test304, test305,
test306, test307, test308, test309,
test306, test307, test308, test309, test310,
test400, test401, test402,
test600,
]
......@@ -62,7 +62,7 @@ def setCurrentData(name):
def print2screen(ClassName, inputArg, *args, **kwargs):
try:
fig = ClassName(inputarg=inputArg, *args, **kwargs)
fig = ClassName(inputArg, *args, **kwargs)
except:
print(SEVR + 'The type of figure you gave does not exists.')
return(False)
......@@ -113,7 +113,7 @@ def drawFigOnWindow(fig, ID):
def giveDataToWindow(data, ID):
fig = getFigOnWindow(ID)
fig.update(inputarg = data)
fig.update(rawdata = data)
win = getWindow(ID)
win.refresh()
......@@ -146,7 +146,7 @@ def closeAllWindows():
def print2file(ClassName, inputArg, filename, *args, **kwargs):
try:
fig = ClassName(inputarg=inputArg, *args, **kwargs)
fig = ClassName(inputArg, *args, **kwargs)
except:
print(SEVR + 'The type of figure you gave does not exists.')
return(False)
......
from myIOs import readStupidData, readStupidData2
from axTest1 import AxTest1
from figTest import FigTest1, FigTest2
from figTest import FigTest2
from tests import myTest
......@@ -9,7 +9,7 @@ from tests import myTest
from tests import test100
from tests import test200, test201, test202
from tests import test300, test301, test302, test303, test304, test305
from tests import test306, test307, test308, test309
from tests import test306, test307, test308, test309, test310
from tests import test400, test401, test402, test403
from tests import test600
......@@ -75,28 +75,6 @@ D_XRANGE = [-1, 1]
D_YRANGE = [-2, 2]
# Class MyFig Overwriting Matplotlib.figure.Figure
class FigTest1(MyFig_base):
# Set the size of the Figure in inch
# (private variable can not be updated)
FIGSIZE = (8., 6.)
# CONSTRUCTOR --------------------------------------------------------
def __init__(self, rawdata, *args, **kwargs):
# parent constructor
MyFig.__init__(self, rawdata, *args, **kwargs)
self.keywords = {'xRange': D_XRANGE,
'yRange': D_YRANGE}
ratio = 6. / 8. # height/width of the axes (in inch)
frame = [0.0, 0.0, 1.0, 1.0] # part of the fig that is available
self.add_axes(AxTest1(self, ratio, frame, *args, **kwargs))
# Class MyFig Overwriting Matplotlib.figure.Figure
class FigTest2(MyFig):
......
......@@ -8,6 +8,7 @@ from .. import G_RAWDATAS, _G_WINDOWS
from . import readStupidData, readStupidData2
from . import FigTest2, AxTest1
# TESTER
def myTest(function, expected, failed, debug):
......@@ -406,7 +407,7 @@ def test308(debug):
G_RAWDATAS.update({'data': MyData()})
G_RAWDATAS['data'].data = [1, -1, -1, 1]
fig.update(rawdata=(G_RAWDATAS['data'],))
fig.plot()
......@@ -441,8 +442,8 @@ def test309(debug):
if fig.rawdata != ('dummy',):
status = False
if(not (fig.debug and fig.reformat and fig.formatted)):
if(not (fig.debug and fig.reformat and not fig.formatted)): # EXPECT: True, True, False
status = False
if not hasattr(fig, 'FIGSIZE'):
......@@ -454,6 +455,31 @@ def test309(debug):
return(status)
# TEST 3.10: test if plot just redraw the axis and reset recreate the axis.
def test310(debug):
status = True
# create environment
data = readStupidData('data1')
fig = FigTest2((data,))
# save current axis
ax = fig.get_axes()[0]
# plot and check if current axis is same as saved
fig.plot()
if(fig.get_axes()[0] != ax):
return(False)
# reset and check if current axis diff than saved
fig.reset()
if(fig.get_axes()[0] == ax):
return(False)
return(status)
# TEST 4.00: test MyWin (EXPECTED: TRUE)
def test400(debug):
......@@ -517,6 +543,7 @@ def test402(debug):
data2 = readStupidData2('data2')
fig = FigTest2((data1,))
formerAxes = fig.get_axes()[0]
if(debug): print(DBUG + "Created a MyFig object with data1.")
win = MyWin(fig)
......@@ -531,6 +558,18 @@ def test402(debug):
if(win.canvas.figure.rawdata != (data2,)):
status = False
if(debug): print(DBUG + "Rawdata are data2, as expected.")
if(win.canvas.figure != fig):
return(False)
if(debug): print(DBUG + "Figure stayed the same, as expected.")
if(win.canvas.figure.get_axes()[0] != formerAxes):
return(False)
if(debug): print(DBUG + "Axes stayed the same, as expected.")
win.close()
del win
......@@ -578,6 +617,75 @@ def test403(debug):
return(status)
# TEST 5.03: getFigOnWindow
def test503(debug):
status = True
data = readStupidData('data1')
fig = FigTest2((data,))
win = MyWin(fig)
if(getFigOnWindow(0) != fig):
status = False
win.close()
del fig
del data
return(status)
# TEST 5.06: closeWindow
def test506(debug):
status = True
data = readStupidData('data1')
fig = FigTest2((data,))
win = MyWin(fig)
closeWindow(0)
if(len(_G_WINDOWS) != 0):
status = False
del win
del fig
del data
return(status)
# TEST 5.00: Testing print2screen
def test500(debug):
status = True
data = readStupidData('data1')
print2screen(FigTest2, (data,))
fig = getFigOnWindow(0)
if(fig.rawdata != (data,)):
status = False
closeWindow(0)
del fig
del data
return(status)
# TEST 5.01: printListCurrentWindows
# TEST 5.02: getWindow
# TEST 5.04: drawFigOnWindow
# TEST 5.05: giveDataToWindow
# TEST 5.07: closeAllWindows
# TEST 5.08: print2file
# TEST 600: Test Adding Axes on the Fly (EXPECTED: True)
def test600(debug):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment