Commit 38c07117 authored by Adam Blank's avatar Adam Blank
Browse files

Add new file

No related merge requests found
Showing with 168 additions and 0 deletions
+168 -0
import importlib
import sys
import pytest
naming = importlib.import_module('tests.helpers.naming', 'lecture-code')
apply_names = naming.apply_names
def fun_tester(f, vals):
if '11.secret' in sys.modules:
del sys.modules['11.secret']
ref = importlib.import_module('11.secret', 'lecture-code')
if '11.code' in sys.modules:
del sys.modules['11.code']
code = importlib.import_module('11.code', 'lecture-code')
reference_values = ['in=' + str(x) + ', out=' +
str(getattr(ref, f)(x)) for x in vals]
student_values = ['in=' + str(x) + ', out=' +
str(getattr(code, f)(x)) for x in vals]
assert reference_values == student_values
def test_f():
fun_tester('f', range(0, 100))
def test_g():
fun_tester('g', range(0, 200))
VEGETABLES = [
"acorn squash",
"alfalfa sprout",
"amaranth",
"anise",
"artichoke",
"arugula",
"asparagus",
"aubergine",
"azuki bean",
"banana squash",
"basil",
"bean sprout",
"beet",
"black bean",
"black-eyed pea",
"bok choy",
"borlotti bean",
"broad beans",
"broccoflower",
"broccoli",
"brussels sprout",
"butternut squash",
"cabbage",
"calabrese",
"caraway",
"carrot",
"cauliflower",
"cayenne pepper",
"celeriac",
"celery",
"chamomile",
"chard",
"chayote",
"chickpea",
"chives",
"cilantro",
"collard green",
"corn",
"corn salad",
"courgette",
"cucumber",
"daikon",
"delicata",
"dill",
"eggplant",
"endive",
"fennel",
"fiddlehead",
"frisee",
"garlic",
"gem squash",
"ginger",
"green bean",
"green pepper",
"habanero",
"herbs and spice",
"horseradish",
"hubbard squash",
"jalapeno",
"jerusalem artichoke",
"jicama",
"kale",
"kidney bean",
"kohlrabi",
"lavender",
"leek ",
"legume",
"lemon grass",
"lentils",
"lettuce",
"lima bean",
"mamey",
"mangetout",
"marjoram",
"mung bean",
"mushroom",
"mustard green",
"navy bean",
"new zealand spinach",
"nopale",
"okra",
"onion",
"oregano",
"paprika",
"parsley",
"parsnip",
"patty pan",
"pea",
"pinto bean",
"potato",
"pumpkin",
"radicchio",
"radish",
"rhubarb",
"rosemary",
"runner bean",
"rutabaga",
"sage",
"scallion",
"shallot",
"skirret",
"snap pea",
"soy bean",
"spaghetti squash",
"spinach",
"squash",
"sweet potato",
"tabasco pepper",
"taro",
"tat soi",
"thyme",
"topinambur",
"tubers",
"turnip",
"wasabi",
"water chestnut",
"watercress",
"white radish",
"yam",
"zucchini"
]
def test_h():
fun_tester('h', VEGETABLES)
def test_i():
fun_tester('i', VEGETABLES)
def test_j():
fun_tester('j', VEGETABLES)
def test_k():
fun_tester('k', [(x, y) for x in VEGETABLES[:15] for y in VEGETABLES[15:]])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment