Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
?
lecture-code
Commits
38c07117
Commit
38c07117
authored
4 months ago
by
Adam Blank
Browse files
Options
Download
Email Patches
Plain Diff
Add new file
parent
6bfd5195
master
rkalahas-master-patch-39159
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/0.Lecture 11/test_mystery.py
+168
-0
tests/0.Lecture 11/test_mystery.py
with
168 additions
and
0 deletions
+168
-0
tests/0.Lecture 11/test_mystery.py
0 → 100644
View file @
38c07117
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
:]])
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help