def test_removeLogging(self): # Log some text output = [] sys.stdout = Logger(output, continueWritingToTerminal=False) testText = "testStatement" print(testText) # Make sure it worked self.assertEqual(output, [testText, '\n']) # Remove the logger removeLogger() # Log some more text, make sure it no longer shows up in the output array print(testText) self.assertEqual(len(output), 2)
def setUp(self): removeLogger() self.dummyVelocity1 = Vector(0, 0, 50) self.dummyVelocity2 = Vector(1, 0, 20) self.dummyVelocity3 = Vector(0, 0, -100) self.dummyOrientation1 = Quaternion(Vector(1, 0, 0), math.radians(2)) self.dummyOrientation2 = Quaternion(Vector(1, 0, 0), math.radians(-2)) self.dummyOrientation3 = Quaternion(Vector(0, 1, 0), math.radians(2)) self.dummyOrientation4 = Quaternion(Vector(1, 0, 0), 0) self.dummyOrientation5 = Quaternion(Vector(1, 1, 0), math.radians(2)) self.dummyOrientation6 = Quaternion(Vector(1, 0, 0), math.radians(90)) self.environment = Environment(silent=True) self.currentConditions = self.environment.getAirProperties( Vector(0, 0, 200)) self.rocketState1 = RigidBodyState( Vector(0, 0, 200), Vector(0, 0, 200), Quaternion(Vector(0, 0, 1), 0), AngularVelocity(rotationVector=Vector(0, 0, 0))) self.rocketState3 = RigidBodyState( Vector(0, 0, 200), Vector(0, 0, 500), Quaternion(Vector(1, 0, 0), math.radians(2)), AngularVelocity(rotationVector=Vector(0, 0, 0))) self.rocketState4 = RigidBodyState( Vector(0, 0, 200), Vector(0, 0, -200), Quaternion(Vector(1, 0, 0), math.radians(180)), AngularVelocity(rotationVector=Vector(0, 0, 0))) self.rocketState8 = RigidBodyState( Vector(0, 0, 200), Vector(20.04, -0.12, -52.78), Quaternion(Vector(0, 1, 0), math.radians(90)), AngularVelocity(rotationVector=Vector(0, 0, 0))) self.correctDynamicPressure1 = self.currentConditions.Density * self.rocketState1.velocity.length( )**2 / 2 self.correctDynamicPressure2 = self.currentConditions.Density * self.rocketState3.velocity.length( )**2 / 2
def tearDown(self): removeLogger()
try: shutil.rmtree('./MAPLEAF/V&V') except: pass # Load the simulation definition file that defines all of the regression verification and validation cases batchDefinition = SimDefinition( './MAPLEAF/Examples/BatchSims/regressionTests.mapleaf') batchRun = BatchRun(batchDefinition) # Run all the cases to generate the result pdfs run(batchRun) resultSummary = [] sys.stdout = Logger(resultSummary) batchRun.printResult() removeLogger() print("Finished running cases") # Create the verification and validation folder, make it a python module (so it gets included in the code documentation) MAPLEAFPath = Path(__file__).parent.parent.parent.parent.absolute() fakeModuleDirectory = MAPLEAFPath / 'MAPLEAF' / 'V&V' fakeModuleDirectory.mkdir(parents=True, exist_ok=True) regressionTestingDirectory = MAPLEAFPath / 'MAPLEAF' / 'Examples' / 'V&V' if regressionTestingDirectory.exists(): print("Regression testing path exists") print("Paths created") # Create __init__.py from template