Best Python code snippet using molecule_python
recipe.py
Source: recipe.py
1class ChocCookies:2 TEST_INGREDIENTS = []3 TEST_INGREDIENTS.append("3/4 cup granulated sugar")4 TEST_INGREDIENTS.append("3/4 cup packed brown sugar")5 TEST_INGREDIENTS.append("1 cup butter or margarine, softened")6 TEST_INGREDIENTS.append("1 teaspoon vanilla")7 TEST_INGREDIENTS.append("1 large egg")8 TEST_INGREDIENTS.append("2 1/4 cups all-purpose flour")9 TEST_INGREDIENTS.append("1 teaspoon baking soda")10 TEST_INGREDIENTS.append("1/2 teaspoon salt")11 TEST_INGREDIENTS.append("1 bag (12oz) semisweet chocolate chips (2 cups)")12 TEST_STEPS = []13 TEST_STEPS.append("Heat oven to 375 degrees F (175 degrees C)")14 TEST_STEPS.append("In large bowl, beat sugars, butter, vanilla and egg with " +15 "electric mixer on medium speed, or mix with spoon. Stir in " +16 "flour, baking soda and salt (dough will be stiff). Stir in " +17 "nuts and chocolate chips.")18 TEST_STEPS.append("On an ungreased cookie sheet, drop dough by rounded tablespoons " +19 "about 2 inches apart.")20 TEST_STEPS.append("Bake 8 to 10 minutes or until light brown (centers will be " +21 "soft). Cool 1 to 2 minutes; remove from cookie sheet wire rack.")22 TEST_PREP = "PT10M"23 TEST_BAKE = "PT9M"24 TEST_TOTAL = "PT20M"25 TEST_NAME = "Chocolate Chip Cookies"26 NUTRITION_INFO = "275"27 OVEN_TEMP = 37528 29class SnowCones:30 TEST_INGREDIENTS = []31 TEST_INGREDIENTS.append("3/4 cup granulated snow")32 TEST_INGREDIENTS.append("1 snow cone")33 TEST_INGREDIENTS.append("7 sprits of water")34 TEST_INGREDIENTS.append("1/4 cup packed yellow snow")35 TEST_STEPS = []36 TEST_STEPS.append("Heat oven to 105 F to warm hands.")37 TEST_STEPS.append("In large bowl, mix the various snows "+38 "with your hands on medium speed for one minute.")39 TEST_STEPS.append("In snow cone cups, drop snow by round balls, about 2 inches" +40 " in diameter.")41 TEST_STEPS.append("Let warm 2 to 3 minutes or until slightly runny. Enjoy!")42 TEST_PREP = "PT2M"43 TEST_BAKE = "PT3M"44 TEST_TOTAL = "PT6M"45 TEST_NAME = "Snow Cones"46 NUTRITION_INFO = "0"...
task1.py
Source: task1.py
...6 for ingredient in ingredients:7 name, capacity, durability, flavor, texture, _ = re.findall(r"[A-Z][a-z]+|[-]?\d+", ingredient)8 ingredient_data[name] = (int(capacity), int(durability), int(flavor), int(texture))9 return ingredient_data10def test_bake(mix, ingredient, stats):11 test_mix = copy(mix)12 test_mix[ingredient] += 113 return calculate_score(test_mix, stats)14def calculate_score(mix, stats):15 c, d, f, t = (0, 0, 0, 0)16 for ingredient, scoops in mix.items():17 c1, d1, f1, t1 = stats[ingredient]18 c, d, f, t = c + c1 * scoops, d + d1 * scoops, f + f1 * scoops, t + t1 * scoops19 return max(0, c) * max(0, d) * max(0, f) * max(0, t)20def optimize_recipe(stats, max_spoons):21 mixture = dict()22 current_teaspoons = 423 # Lets start with one of each ingredient24 for ingredient in stats.keys():25 mixture[ingredient] = 126 while current_teaspoons < max_spoons:27 mixes = ((ingredient, test_bake(mixture, ingredient, stats)) for ingredient in stats.keys())28 ingredient, score = max(mixes, key=lambda m: m[1]) # m[1] = score29 mixture[ingredient] += 130 current_teaspoons += 131 return mixture32if __name__ == "__main__":33 ingredient_stats = read_ingredients("input.txt")34 optimal_recipe = optimize_recipe(stats=ingredient_stats, max_spoons=100)...
test_pizza.py
Source: test_pizza.py
...7def test_recipes(s, exp):8 """ТеÑÑиÑÑем ÑеÑепÑÑ"""9 assert s.dict() == exp10random.seed(10)11def test_bake():12 """ТеÑÑиÑÑем декоÑаÑÐ¾Ñ Ð¸ ÑÑнкÑÐ¸Ñ bake"""13 assert bake() == 'bake - 19 минÑÑ!'14@pytest.mark.parametrize('s,exp', [(Hawaiian('S'), 'L'),15 (Pepperoni('XL'), 'XL'),16 (Spinach('L'), 'L')])17def test_size(s, exp):18 """ТеÑÑиÑÑем ÑазмеÑÑ"""...
Check out the latest blogs from LambdaTest on this topic:
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.
Most test automation tools just do test execution automation. Without test design involved in the whole test automation process, the test cases remain ad hoc and detect only simple bugs. This solution is just automation without real testing. In addition, test execution automation is very inefficient.
I was once asked at a testing summit, “How do you manage a QA team using scrum?” After some consideration, I realized it would make a good article, so here I am. Understand that the idea behind developing software in a scrum environment is for development teams to self-organize.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!