Created
September 28, 2014 17:16
-
-
Save VictorSouzas/167c124d031b87d25441 to your computer and use it in GitHub Desktop.
teste random
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
# -*- coding: utf-8 -*- | |
import random | |
import unittest | |
def gen_age(): | |
# gera numeros inteiros entre 15 e 99 | |
return random.randint(15, 99) | |
class AgeTest(unittest.TestCase): | |
def setUp(self): | |
self.a = gen_age() | |
self.lista = range(15, 99) | |
def test_choice(self): | |
#testa se o numero é maior ou igual a 15 | |
self.assertGreaterEqual(self.a, 15) | |
#testa se o numero é menor ou igual a 99 | |
self.assertLess(self.a, 99) | |
def test_sample(self): | |
for self.a in random.sample(self.lista, 5): | |
#testa se o numero é maior ou igual a 15 | |
self.assertGreaterEqual(self.a, 15) | |
#testa se o numero é menor ou igual a 99 | |
self.assertLess(self.a, 99) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment