This is a python file Fix this code and the output is the attachment #filename: modValidateEmail.py def isValidMSUMEmail(email): if email.count('@') != 1: return False tmp= email.split('@') if len(tmp) == 0: return False userName = tmp[0] if not userName[0].isalpha(): return False for c in userName: if not c.isalpha() and c != '.': return False inst= tmp[1] if inst != 'mnstate.edu': return False else: return True #filename: UnitTestValidEmail.py from unittest import * from modValidateEmail import * class TestValidEmail(TestCase): #create a subclass of unittest.TestCase def testUserName(self): self.assertEqual(isValidMSUMEmail('.joe@mnstate.edu'),False) self.assertEqual(isValidMSUMEmail('joe4@mnstate.edu'),False) self.assertEqual(isValidMSUMEmail('joe$smith@mnstate.edu'),False) self.assertEqual(isValidMSUMEmail('joe.smith@mnstate.edu'),True) def testTooManyAmpersands(self): self.assertEqual(isValidMSUMEmail('jim@smith@mnstate.edu'), False) self.assertEqual(isValidMSUMEmail('@jim@smith@mnstate.edu'),False) def testNotMnstate(self): self.assertEqual(isValidMSUMEmail('jim.smith@mnstate.com'), False) def testGoodEmail(self): self.assertEqual(isValidMSUMEmail('jesse.jones@mnstate.edu'),True) #main #unittest.main() suite = TestLoader().loadTestsFromTestCase(TestValidEmail) TextTestRunner(verbosity=2).run(suite) OUTPUT:
This is a python file
Fix this code and the output is the attachment
#filename: modValidateEmail.py def isValidMSUMEmail(email): if email.count('@') != 1: return False tmp= email.split('@') if len(tmp) == 0: return False userName = tmp[0] if not userName[0].isalpha(): return False for c in userName: if not c.isalpha() and c != '.': return False inst= tmp[1] if inst != 'mnstate.edu': return False else: return True |
#filename: UnitTestValidEmail.py from unittest import * from modValidateEmail import *
class TestValidEmail(TestCase): #create a subclass of unittest.TestCase def testUserName(self): self.assertEqual(isValidMSUMEmail('.joe@mnstate.edu'),False) self.assertEqual(isValidMSUMEmail('joe4@mnstate.edu'),False) self.assertEqual(isValidMSUMEmail('joe$smith@mnstate.edu'),False) self.assertEqual(isValidMSUMEmail('joe.smith@mnstate.edu'),True)
def testTooManyAmpersands(self): self.assertEqual(isValidMSUMEmail('jim@smith@mnstate.edu'), False) self.assertEqual(isValidMSUMEmail('@jim@smith@mnstate.edu'),False)
def testNotMnstate(self): self.assertEqual(isValidMSUMEmail('jim.smith@mnstate.com'), False)
def testGoodEmail(self): self.assertEqual(isValidMSUMEmail('jesse.jones@mnstate.edu'),True)
#main #unittest.main() suite = TestLoader().loadTestsFromTestCase(TestValidEmail) TextTestRunner(verbosity=2).run(suite) |
OUTPUT:
|
Step by step
Solved in 2 steps with 2 images