def test_legal_names(self): """ Testing to see if names are legal. """ case = generate_products() for product in case: adjective, noun = product.name.split() self.assertIn(adjective, ADJECTIVES) self.assertIn(noun, NOUNS)
def test_legal_names(self): """Tests that the names have proper Acme names""" case = generate_products() for product in case: adjective, noun = product.name.split() self.assertIn(adjective, ADJECTIVES) self.assertIn(noun, NOUNS)
def test_legal_names(self): '''Test generated product names for compliance with English grammar''' products = generate_products() name_list = [item.name.split(' ', 1) for item in products] for name in name_list: self.assertIn(name[0], ADJECTIVES) self.assertIn(name[1], NOUNS)
def test_legal_names(self): """tests that product names are legal""" products = generate_products() for i in range(len(products)): nameSplit = products[i].name.split() self.assertIn(nameSplit[0], ADJECTIVES) self.assertIn(nameSplit[1], NOUNS)
def test_legal_names(self): name = generate_products()[1][1] for nouns in noun: self.assertIn(name, nouns) for adjectives in adjective: self.assertIn(name, adjectives) self.assertIn('', name)
def test_legal_names(self): '''Ensure product names are valid''' prod = generate_products() for product in prod: name = product.name.split() self.assertIn(name[0], adj) self.assertIn(name[1], noun)
def test_default_num_products(self): """ Test that products really does receive a list of default length 30 """ products = generate_products() self.assertEqual(len(products), 30)
def test_default_num_products(self): '''Testing if the default number of products is 30''' # I'm not quite sure what to do, but you can see what I'm trying at least! prod_list = generate_products() len(prod_list[::4]) self.assertEqual(len(prod_list[::4]), 30)
def test_legal_names(self): products = generate_products() for product in products: adj = product.name[0] noun = product.name[1] self.assertIn(adj, ADJECTIVES) self.assertIn(noun, NOUNS)
def test_legal_names(self): list = generate_products() for x in list: name = x[0] self.assertIs(type(name), tuple) self.assertIn(name[0], ADJECTIVES) self.assertIn(name[1], NOUNS)
def test_legal_names(self): """Tests that the generated names are valid names generate""" products = generate_products() for prod in products: name = prod.name.split(" ") self.assertIn(name[0], ADJECTIVES) self.assertIn(name[1], NOUNS)
def test_default_num_products(self): products = generate_products() self.assertEqual(len(products), 30) for product in products: split = product.name.split() self.assertIn(split[0], possible_adj) self.assertIn(split[1], possible_noun)
def test_default_num_products(self): ''' Checks that number of default products created is 30 ''' prods = generate_products() self.assertEqual(len(prods), 30)
def test_legal_names(self): word = generate_products()[0] word1, word2 = word.name.split() word1 = word1.strip('[').strip(']').strip("'") word2 = word2.strip('[').strip(']').strip("'") self.assertIn(word1, ADJECTIVES) self.assertIn(word2, NOUNS)
def test_legal_names(self): r = generate_products() for product in r: first = product.name.split()[0] second = product.name.split()[1] self.assertIn(first, ADJECTIVES) self.assertIn(second, NOUNS)
def test_legal_names(self): '''Test that generated product names are valid''' prods = generate_products() for prod in prods: start, end = prod.name.split(' ') self.assertIn(start, ADJECTIVES) self.assertIn(end, NOUNS)
def test_legal_names(self): for product in generate_products(): name = product.name self.assertEqual(name.count(' '), 1) adj, noun = name.split(' ') self.assertIn(adj, ADJECTIVES) self.assertIn(noun, NOUNS)
def test_legal_names(self): """Ensure that generated products' names are valid.""" items = generate_products() for item in items: an_adjective, a_noun = item.name.split(' ') self.assertIn(an_adjective, adj) self.assertIn(a_noun, noun)
def test_legal_names(self): """Making sure names for products are legal.""" products = generate_products() NAMES = ADJECTIVES + NOUNS for product in products: for word in product.name.split(): self.assertIn(word, NAMES)
def test_default_num_products(self): """ checks that it really does receive a list of length 30 """ products_test_report = generate_products() self.assertEqual(len(products_test_report), 30)
def test_legal_names(self): """Test generated names""" prod_names = [prod.name for prod in generate_products()] for prod in prod_names: splt = prod.split() self.assertIn(splt[0], ADJECTIVES) self.assertIn(splt[1], NOUNS)
def test_legal_names(self): '''Test that generated product names are valid''' prods = generate_products() for prod in prods: start, end = prod.name.split(' ') self.assertIn(start, adjectives) self.assertIn(end, products)
def test_legal_names(self): """ checks that the generated names for a default batch of products are all valid possible names to generate (adjective, space, noun, from the lists of possible words) """ products = generate_products() check_for_adj = [] check_for_noun = [] for i in range(len(products)): """ Split and collect the first and second words of each product in a list. Check if the first names match to adjectives and the second to nouns """ name = str(products[i]).split() check_for_adj += [name[0]] check_for_nouns += [name[1]] for j in range(len(set(check_for_adj))): self.assertIn(list(set(check_for_adj))[j], ADJECTIVES) for k in range(len(set(check_for_noun))): self.assertIn(list(set(check_for_nouns))[k], NOUNS)
def test_explodability(self): '''situation where explodability should print ...fizzle.''' gameboy = Product(weight=2, flammability=2) self.assertEqual(gameboy.explodability(), '...fizzle.') '''situation where explodability should print ...boom!''' shaving_cream = Product(weight=3, flammability=10) self.assertEqual(shaving_cream.explodability(), '...boom!') '''situation where explodability should print ...BABOOM!!' pie = Product(weight=1, flammability=100) self.assertEqual(pie.explodability(), '...BABOOM!!') class AcmeReportTests(unittest.TestCase): '''making sure Acme tests are scientifically cutthroat''' def test_default_num_products(self): '''confirms 30 products are generated by default''' products = generate_products() self.assertEqual(len(products), 30) def test_legal_names(self): '''confirms product names are valid''' products = generate_products() names = [] for prod in products: names.append(prod[0]) unique_names = [] for name in names: if name not in unique_names: unique_names.append(name) self.assertIn(NOUNS, unique_names) self.assertIn(ADJECTIVES, unique_names)
def test_legal_names(self): """Checking that all products generated have valid names""" for product in generate_products(): adjective, noun = product.name.split() self.assertIn(adjective, adjectives) self.assertIn(noun, nouns) self.assertIn(' ', product.name)
def test_legal_names(self): prod = generate_products(name, price, weight, flammability, num_products=1) self.assertIn(prod[0].name, name)
def test_report_price_range(self): """ Confirm price range acceptable limits. """ report = generate_report(generate_products()) self.assertGreaterEqual(min(report[1]), 5.00) self.assertLessEqual(max(report[1]), 1938.67)
def test_legal_names(self): """Test legal names.""" products = generate_products() valid_names = [ first + ' ' + second for first in ADJECTIVES for second in NOUNS ] [self.assertIn(product.name, valid_names) for product in products]
def test_legal_names(self): prod_list = generate_products() for prod in prod_list: n = prod.name n = n.split(" ") self.assertIn(n[0],ADJECTIVES) self.assertIn(n[1],NOUNS)
def test_legal_names(self): product_list = generate_products() for product in product_list: words = product.name.split(sep=' ') self.assertEqual(len(words), 2) self.assertIn(words[0], ADJECTIVES) self.assertIn(words[1], NOUNS)