Nov-15-2020, 04:41 PM
I want to write the results of my unit tests into a text file but it does not seem to be working. Here is my code:
I shall be grateful if someone can please help?
unit tests:
Writing to a text file. Here is the problem
I shall be grateful if someone can please help?
unit tests:
Quote:import unittest
import validate_setup
import sys
class TestValidateSetup(unittest.TestCase):
df = validate_setup.reading_excel()
def test_validate_setup_mesh_size(self):
self.assertEqual(TestValidateSetup.df.iloc[0,1], 0.3)
def test_validate_setup_stresses_max_von_mises(self):
self.assertEqual(TestValidateSetup.df.iloc[1,1], 300)
def test_validate_setup_stresses_min_von_mises(self):
self.assertEqual(TestValidateSetup.df.iloc[2,1], 300)
def test_validate_setup_stresses_max_principal(self):
self.assertEqual(TestValidateSetup.df.iloc[3,1], 400)
def test_validate_setup_stresses_min_principal(self):
self.assertEqual(TestValidateSetup.df.iloc[4,1], 50)
Writing to a text file. Here is the problem
Quote:def main(out = sys.stderr, verbosity = 2):
loader = unittest.TestLoader()
suite = loader.loadTestsFromModule(sys.modules[__name__])
unittest.TextTestRunner(out, verbosity = verbosity).run(suite)
if __name__ == '__main__':
with open('testing.out', 'w') as f:
main(f)