Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue169 fix #297

Open
wants to merge 6 commits into
base: 2025/x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions finance/.cs50.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ check50:
files: &check50_files
- !exclude "*.pyc"
- !exclude __pycache__
- !exclude venv
- !require app.py
- !require finance.db
- !require helpers.py
Expand Down
6 changes: 3 additions & 3 deletions finance/lookup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
def lookup(symbol):
symbol = symbol.upper()
if (symbol == "AAAA"):
return {"price": 28.00, "symbol": "AAAA"}
return {"name": "AAAA stock", "price": 28.00, "symbol": "AAAA"}
elif (symbol == "BBBB"):
return {"price": 14.00, "symbol": "BBBB"}
return {"name": "BBBB stock", "price": 14.00, "symbol": "BBBB"}
elif (symbol == "CCCC"):
return {"price": 2000.00, "symbol": "CCCC"}
return {"name": "CCCC stock", "price": 2000.00, "symbol": "CCCC"}
else:
return None
8 changes: 2 additions & 6 deletions movies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def test9():
"Rupert Grint",
"Daniel Radcliffe",
"Emma Watson",
"Emma Watson",
],
ordered=True,
)
Expand Down Expand Up @@ -222,17 +221,14 @@ def check_single_col(actual, expected, ordered=False):
# Get data from column
try:
result = [str(list(row.values())[0]) for row in actual]
result = result if ordered else set(result)
except IndexError:
return None

# Check column data against expected values
expected = [str(value) for value in expected]

# If unordered, sort both before checking
if not ordered:
result.sort()
expected.sort()

expected = set(expected)
if result != expected:
raise check50.Mismatch("\n".join(expected), "\n".join(list(result)))

Expand Down
Binary file modified movies/movies.db
Binary file not shown.
35 changes: 28 additions & 7 deletions speller/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,33 @@ def basic():
def min_length():
"""handles min length (1-char) words"""
check50.include("min_length")
check50.run("./speller min_length/dict min_length/text").stdout(open("min_length/out")).exit(0)
check50.run("./speller min_length/dict min_length/text").stdout(
open("min_length/out")
).exit(0)


@check50.check(compiles)
def max_length():
"""handles max length (45-char) words"""
check50.include("max_length")
check50.run("./speller max_length/dict max_length/text").stdout(open("max_length/out")).exit(0)
check50.run("./speller max_length/dict max_length/text").stdout(
open("max_length/out")
).exit(0)


@check50.check(compiles)
def apostrophe():
"""handles words with apostrophes properly"""
check50.include("apostrophe")
check50.run("./speller apostrophe/without/dict apostrophe/with/text").stdout(open("apostrophe/outs/without-with")).exit(0)
check50.run("./speller apostrophe/with/dict apostrophe/without/text").stdout(open("apostrophe/outs/with-without")).exit(0)
check50.run("./speller apostrophe/with/dict apostrophe/with/text").stdout(open("apostrophe/outs/with-with")).exit(0)
check50.run("./speller apostrophe/without/dict apostrophe/with/text").stdout(
open("apostrophe/outs/without-with")
).exit(0)
check50.run("./speller apostrophe/with/dict apostrophe/without/text").stdout(
open("apostrophe/outs/with-without")
).exit(0)
check50.run("./speller apostrophe/with/dict apostrophe/with/text").stdout(
open("apostrophe/outs/with-with")
).exit(0)


@check50.check(compiles)
Expand All @@ -59,10 +69,21 @@ def case():
def substring():
"""handles substrings properly"""
check50.include("substring")
check50.run("./speller substring/dict substring/text").stdout(open("substring/out")).exit(0)
check50.run("./speller substring/dict substring/text").stdout(
open("substring/out")
).exit(0)


@check50.check(compiles)
def large_dict():
"""handles large dictionary (hash collisions) properly"""
check50.include("large")
check50.run("./speller large/dict large/text").stdout(open("large/out")).exit(0)


@check50.check(substring)
def memory():
"""program is free of memory errors"""
check50.c.valgrind("./speller substring/dict substring/text").stdout(open("substring/out"), timeout=10).exit(0)
check50.c.valgrind("./speller substring/dict substring/text").stdout(
open("substring/out"), timeout=10
).exit(0)
Loading