Last active
December 21, 2015 06:38
-
-
Save IuryAlves/6265051 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
def fat(n): | |
if n == 1 or n == 0: | |
return n | |
return fat(n - 1) * n; | |
class Test(unittest.TestCase): | |
@classmethod | |
def tearDownClass(cls): # metodo que e executado apos a execucao dos testes | |
print("\nTodos os testes foram executados") | |
@classmethod | |
def setUpClass(cls): | |
print("\n Os testes serao executados =D") | |
def test_1(self): | |
self.assertEquals(1,fat(1) ) | |
def test_2(self): | |
self.assertEquals(2,fat(2) ) | |
def test_5(self): | |
self.assertEquals(120,fat(5) ) | |
def test_int(self): | |
self.assertTrue(int == type( fat(2) )) | |
@unittest.expectedFailure | |
def test_not_int(self): | |
self.assertFalse( int != type( fat(1.2) )) | |
@unittest.expectedFailure | |
def test_negativo(self): | |
self.assertRaises(RuntimeError,fat(-1)) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment