Skip to content

Instantly share code, notes, and snippets.

@IuryAlves
Last active December 21, 2015 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IuryAlves/6265051 to your computer and use it in GitHub Desktop.
Save IuryAlves/6265051 to your computer and use it in GitHub Desktop.
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