def setUp(self): # SimulationRoot is static and so some junk can be left # over from other tests when running under nose, so # set it to cwd here just to be safe SimulationRoot.chroot(os.getcwd()) self.asm = set_as_top(Assembly()) obj = self.asm.add('scomp1', SimpleComp()) self.asm.add('scomp2', SimpleComp()) self.asm.driver.workflow.add(['scomp1', 'scomp2']) with self.asm.dir_context: filename = 'top.data.vt' with open(filename, 'w') as out: out.write('vt data\n') obj.cont_in.data = FileRef(filename, self.asm) filename = 'top.data.vt2' with open(filename, 'w') as out: out.write('vt2 data\n') obj.cont_in.vt2.data = FileRef(filename, self.asm) filename = 'top.data.vt3' with open(filename, 'w') as out: out.write('vt3 data\n') obj.cont_in.vt2.vt3.data = FileRef(filename, self.asm)
def tearDown(self): """ Called after each test in this class. """ self.model.pre_delete() # Paranoia. Only needed by NPSS I think. self.model = None os.chdir(self.startdir) SimulationRoot.chroot(self.startdir) if not os.environ.get('OPENMDAO_KEEPDIRS', False): try: shutil.rmtree(self.tempdir) except OSError: pass # Not always added, but we need to ensure the egg is not in sys.path. egg_name = self.egg_name paths = sys.path if egg_name is not None: if sys.platform == "win32": egg_name = egg_name.lower() paths = [path.lower() for path in sys.path] for i, path in enumerate(paths): if path.endswith(egg_name) or egg_name in path: del sys.path[i] break
def setUp(self): # SimulationRoot is static and so some junk can be left # over from other tests when running under nose, so # set it to cwd here just to be safe SimulationRoot.chroot(os.getcwd()) pcompmod._count = 0 self.asm = set_as_top(Assembly()) obj = self.asm.add('scomp1', SimpleComp()) self.asm.add('scomp2', SimpleComp()) self.asm.driver.workflow.add(['scomp1', 'scomp2']) with self.asm.dir_context: filename = 'top.data.vt' with open(filename, 'w') as out: out.write('vt data\n') obj.cont_in.data = FileRef(filename, self.asm) filename = 'top.data.vt2' with open(filename, 'w') as out: out.write('vt2 data\n') obj.cont_in.vt2.data = FileRef(filename, self.asm) filename = 'top.data.vt3' with open(filename, 'w') as out: out.write('vt3 data\n') obj.cont_in.vt2.vt3.data = FileRef(filename, self.asm)
def setUp(self): """ Called before each test in this class. """ self.startdir = os.getcwd() self.tempdir = tempfile.mkdtemp(prefix='test_file-') os.chdir(self.tempdir) SimulationRoot.chroot(self.tempdir) self.model = set_as_top(Model())
def setUp(self): SimulationRoot.chroot(DIRECTORY) with open(INP_FILE, 'w') as out: out.write(INP_DATA) if os.path.exists(ENV_FILE): os.remove(ENV_FILE) dum = Assembly() # create this here to prevent any Assemblies in tests to be 'first'
def tearDown(self): os.chdir(self.startdir) SimulationRoot.chroot(self.startdir) if not os.environ.get('OPENMDAO_KEEPDIRS', False): try: shutil.rmtree(self.tempdir) except OSError: pass
def tearDown(self): """ Called after each test in this class. """ os.chdir(self.startdir) SimulationRoot.chroot(self.startdir) if not os.environ.get('OPENMDAO_KEEPDIRS', False): try: shutil.rmtree(self.tempdir) except OSError: pass
def setUp(self): self.tempdir = tempfile.mkdtemp(prefix='test_pbs-') self.startdir = os.getcwd() os.chdir(self.tempdir) SimulationRoot.chroot(self.tempdir) # Force use of fake 'qsub'. self.orig_qsub = list(PBS_Server._QSUB) PBS_Server._QSUB[:] = \ ['python', os.path.join(TestCase.directory, 'pbs_qsub.py')]
def tearDown(self): GridEngineServer._QSUB[:] = self.orig_qsub GridEngineAllocator._QHOST[:] = self.orig_qhost os.chdir(self.startdir) SimulationRoot.chroot(self.startdir) if not os.environ.get('OPENMDAO_KEEPDIRS', False): try: shutil.rmtree(self.tempdir) except OSError: pass
def setUp(self): self.startdir = os.getcwd() self.tempdir = tempfile.mkdtemp(prefix='test_stl-') os.chdir(self.tempdir) SimulationRoot.chroot(self.tempdir) self.top = set_as_top(Assembly()) self.top.add('plug_noz', PlugNozzleGeometry()) self.top.driver.workflow.add('plug_noz') self.top.run()
def setUp(self): random.seed(10) numpy_random.seed(10) self.startdir = os.getcwd() self.tempdir = tempfile.mkdtemp(prefix='test_caseiter-') os.chdir(self.tempdir) SimulationRoot.chroot(self.tempdir) #os.chdir(self.directory) self.model = set_as_top(MyModel()) self.generate_cases()
def setUp(self): global TMPDIR self.startdir = os.getcwd() self.tempdir = tempfile.mkdtemp(prefix='test_extcode-') TMPDIR = self.tempdir os.chdir(self.tempdir) SimulationRoot.chroot(self.tempdir) shutil.copy(os.path.join(DIRECTORY, 'sleep.py'), os.path.join(self.tempdir, 'sleep.py')) with open(INP_FILE, 'w') as out: out.write(INP_DATA) dum = Assembly() # create this here to prevent any Assemblies in tests to be 'first'
def setUp(self): global TMPDIR self.startdir = os.getcwd() self.tempdir = tempfile.mkdtemp(prefix='test_extcode-') TMPDIR = self.tempdir os.chdir(self.tempdir) SimulationRoot.chroot(self.tempdir) shutil.copy(os.path.join(DIRECTORY, 'sleep.py'), os.path.join(self.tempdir, 'sleep.py')) with open(INP_FILE, 'w') as out: out.write(INP_DATA) dum = Assembly( ) # create this here to prevent any Assemblies in tests to be 'first'
def setUp(self): """ Called before each test in this class. """ self.startdir = os.getcwd() self.tempdir = tempfile.mkdtemp(prefix='test_eggsave-') os.chdir(self.tempdir) SimulationRoot.chroot(self.tempdir) self.model = set_as_top(Model()) self.model.name = 'Egg_TestModel' self.child_objs = [self.model.Source, self.model.Sink, self.model.Oddball, self.model.Oddball.oddcomp, self.model.Oddball.oddcont] self.egg_name = None
def tearDown(self): for directory in ('a', 'b'): if os.path.exists(directory): shutil.rmtree(directory) if os.path.exists("error.out"): try: os.remove("error.out") # Windows processes greedily clutch files. I see no # way to delete this file in test_timeout except WindowsError: pass SimulationRoot.chroot(ORIG_DIR)
def tearDown(self): for directory in ("a", "b"): if os.path.exists(directory): shutil.rmtree(directory) if os.path.exists("error.out"): try: os.remove("error.out") # Windows processes greedily clutch files. I see no # way to delete this file in test_timeout except WindowsError: pass SimulationRoot.chroot(ORIG_DIR)
def setUp(self): self.tempdir = tempfile.mkdtemp(prefix='test_ge-') self.startdir = os.getcwd() os.chdir(self.tempdir) SimulationRoot.chroot(self.tempdir) # Force use of fake 'qsub'. self.orig_qsub = list(GridEngineServer._QSUB) GridEngineServer._QSUB[:] = \ ['python', os.path.join(TestCase.directory, 'ge_qsub.py')] # Force use of fake 'qhost'. self.orig_qhost = list(GridEngineAllocator._QHOST) GridEngineAllocator._QHOST[:] = \ ['python', os.path.join(TestCase.directory, 'ge_qhost.py')]
def tearDown(self): for directory in ('a', 'b'): if os.path.exists(directory): shutil.rmtree(directory, onerror=onerror) for name in (ENV_FILE, INP_FILE, 'input', 'output', 'sleep.in', 'sleep.out', 'sleep.err'): if os.path.exists(name): os.remove(name) if os.path.exists("error.out"): try: os.remove("error.out") # Windows processes greedily clutch files. I see no # way to delete this file in test_timeout except WindowsError: pass SimulationRoot.chroot(ORIG_DIR)
def setUp(self): """ top comp1 nested comp1 comp2 comp3 """ SimulationRoot.chroot(os.getcwd()) top = self.asm = set_as_top(Assembly()) top.add("comp1", DummyComp()) nested = top.add("nested", Assembly()) nested.add("comp1", DummyComp()) for name in ["comp2", "comp3"]: top.add(name, DummyComp()) top.driver.workflow.add(["comp1", "nested", "comp2", "comp3"]) nested.driver.workflow.add("comp1")
def setUp(self): """ top comp1 nested comp1 comp2 comp3 """ SimulationRoot.chroot(os.getcwd()) top = self.asm = set_as_top(Assembly()) top.add('comp1', DummyComp()) nested = top.add('nested', Assembly()) nested.add('comp1', DummyComp()) for name in ['comp2', 'comp3']: top.add(name, DummyComp()) top.driver.workflow.add(['comp1', 'nested', 'comp2', 'comp3']) nested.driver.workflow.add('comp1')
def setUp(self): SimulationRoot.chroot(DIRECTORY) self.model = None
def tearDown(self): SimulationRoot.chroot(ORIG_DIR)
def setUp(self): SimulationRoot.chroot(DIRECTORY)