def setup(self): self.temp_dir = mkdtemp() self.allComp = getAllComponents(fetchIcons=False) self.exp = Experiment() # create once, not every test # Create correctScript subdir for holding correct scripts if not os.path.isdir(os.path.join(TESTS_DATA_PATH, "correctScript", "js")): os.mkdir(os.path.join(TESTS_DATA_PATH, "correctScript", "js"))
def setup(self): self.temp_dir = mkdtemp() self.allComp = getAllComponents(fetchIcons=False) self.exp = Experiment() # create once, not every test # Create correctScript subdir for holding correct scripts if not os.path.isdir(os.path.join(TESTS_DATA_PATH, "correctScript", "js")): os.mkdir(os.path.join(TESTS_DATA_PATH, "correctScript", "js"))
def setup(self): self.temp_dir = mkdtemp() self.allComp = getAllComponents(fetchIcons=False) self.exp = Experiment() # create once, not every test self.exp.addRoutine('trial') self.exp.flow.addRoutine(self.exp.routines['trial'], pos=0) # Create correctScript subdir for holding correct scripts if not os.path.isdir(os.path.join(TESTS_DATA_PATH, "correctScript", "python")): os.mkdir(os.path.join(TESTS_DATA_PATH, "correctScript", "python"))
def setup(self): self.temp_dir = mkdtemp() self.allComp = getAllComponents(fetchIcons=False) self.exp = Experiment() # create once, not every test self.exp.addRoutine('trial') self.exp.flow.addRoutine(self.exp.routines['trial'], pos=0) # Create correctScript subdir for holding correct scripts if not os.path.isdir(os.path.join(TESTS_DATA_PATH, "correctScript", "python")): os.mkdir(os.path.join(TESTS_DATA_PATH, "correctScript", "python"))
def setup_class(cls): cls.exp = experiment.Experiment() # create once, not every test cls.here = os.path.abspath(os.path.dirname(__file__)) cls.baselineProfile = os.path.join(cls.here, profile) # should not need a wx.App with fetchIcons=False try: cls.allComp = getAllComponents(fetchIcons=False) except Exception: import wx if parse_version(wx.__version__) < parse_version('2.9'): tmpApp = wx.PySimpleApp() else: tmpApp = wx.App(False) try: from psychopy.app import localization except Exception: pass # not needed if can't import it cls.allComp = getAllComponents(fetchIcons=False)
def setup_class(cls): cls.exp = experiment.Experiment() # create once, not every test cls.here = os.path.abspath(os.path.dirname(__file__)) cls.baselineProfile = os.path.join(cls.here, profile) # should not need a wx.App with fetchIcons=False try: cls.allComp = getAllComponents(fetchIcons=False) except Exception: import wx if parse_version(wx.__version__) < parse_version('2.9'): tmpApp = wx.PySimpleApp() else: tmpApp = wx.App(False) try: from psychopy.app import localization except Exception: pass # not needed if can't import it cls.allComp = getAllComponents(fetchIcons=False)
def test_all_components(): for compName, compClass in experiment.getAllComponents().items(): if compName == "SettingsComponent": continue # Make a generic testing object for this component tester = _Generic(compClass) # Run each method from _TestBaseComponentsMixin on tester for attr, meth in _TestBaseComponentsMixin.__dict__.items(): if inspect.ismethod(meth): meth(tester) # Run each method from _TestBaseComponentsMixin on tester for attr, meth in _TestDisabledMixin.__dict__.items(): if inspect.ismethod(meth): meth(tester)
def getAllIcons(folderList=(), forceReload=False): """load the icons for all the components """ global _allIcons if forceReload or _allIcons is None: compons = experiment.getAllComponents(folderList) _allIcons = {} for thisName, thisCompon in compons.items(): if thisName in components.iconFiles: _allIcons[thisName] = getIcons(components.iconFiles[thisName]) else: _allIcons[thisName] = getIcons(None) return _allIcons else: return _allIcons
def setup(self): # Create experiment and test components exp = Experiment() allComp = getAllComponents(fetchIcons=False) # Polygon self.polygonComp = allComp["PolygonComponent"](parentName='trial', exp=exp) self.polygonComp.params['units'].val = 'height' self.polygonComp.params['startType'].val = "time (s)" self.polygonComp.params['stopType'].val = "time (s)" # Code component self.codeComp = allComp["CodeComponent"](parentName='trial', exp=exp) self.codeComp.params['Begin Experiment'].val = "(\n" self.codeComp.params['Begin JS Experiment'].val = "{\n" # Set ErrorHandler sys.stderr = self.error = _BaseErrorHandler()
def setup(self): # Make a basic experiment with one routine self.exp = experiment.Experiment() self.rt = self.exp.addRoutine("testRoutine") self.exp.flow.addRoutine(self.rt, 0) # Add one of every component to that routine (default params) for compName, compClass in experiment.getAllComponents().items(): if compClass != SettingsComponent: comp = compClass(exp=self.exp, parentName=self.rt.name, name=f"test{compName}") self.rt.append(comp) # Add one of every standalone routine for rtName, rtClass in experiment.getAllStandaloneRoutines().items(): rt = rtClass(exp=self.exp, name=f"test{rtName}") self.exp.addStandaloneRoutine(rt.name, rt) # Add all routines to the flow for rt in self.exp.routines.values(): self.exp.flow.addRoutine(rt, 0)
def getAllIcons(folderList=(), forceReload=False): """load the icons for all the components """ global _allIcons if forceReload or _allIcons is None: compons = experiment.getAllComponents(folderList) _allIcons = {} for thisName, thisCompon in compons.items(): if thisName in components.iconFiles: # darkmode paths if "base.png" not in components.iconFiles[thisName]: components.iconFiles[thisName] = join( dirname(components.iconFiles[thisName]), 'classic' if prefs.app['iconset'] == 'classic' else ('light', 'dark')[prefs.app['darkmode']], basename(components.iconFiles[thisName])) _allIcons[thisName] = getIcons(components.iconFiles[thisName]) else: _allIcons[thisName] = getIcons(None) return _allIcons else: return _allIcons
def setup(self): # Set ErrorHandler self.error = _BaseErrorHandler() # Create experiment, trial, flow and test components self.exp = Experiment() trial = self.exp.addRoutine('trial') self.exp.flow.addRoutine(trial, 0) allComp = getAllComponents(fetchIcons=False) # Polygon self.polygonComp = allComp["PolygonComponent"](parentName='trial', exp=self.exp) trial.addComponent(self.polygonComp) self.polygonComp.params['units'].val = 'height' self.polygonComp.params['startType'].val = "time (s)" self.polygonComp.params['stopType'].val = "time (s)" # Code component self.codeComp = allComp["CodeComponent"](parentName='trial', exp=self.exp) self.codeComp.params['Begin Experiment'].val = "(\n" self.codeComp.params['Begin JS Experiment'].val = "{\n"