Skip to content
Merged
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
16 changes: 15 additions & 1 deletion numb3rs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import check50
import sys
from os import rename
from shutil import rmtree
from re import escape, sub

Expand Down Expand Up @@ -140,7 +142,7 @@ def test_implementation(base_filename, implementation_filename, test_filename, c
"""Test implementation_file, an implementation of base_file, against student's checks in test_file. Expect a given exit status"""

check50.include("pytest_helper.py")
check50.include(implementation_filename)
include_pyc(implementation_filename.removesuffix(".pyc"))

# Overwrite base_file with code to run implementation_file
with open(base_filename, "w") as base_file, open("pytest_helper.py", "r") as pytest_helper:
Expand All @@ -160,3 +162,15 @@ def test_implementation(base_filename, implementation_filename, test_filename, c

# Expect that pytest will exit with given status code
return check50.run(f"pytest {test_filename}").exit(code=code)


def include_pyc(name):
"""Include name.pyc compiled for the running Python.

Bytecode is specific to a Python minor version: executing a mismatch crashes the
interpreter. The checks ship name.cpython-<major><minor>.pyc for each supported
version (from cs50/cs50p-pytest-tests); include the right one under the plain name.
"""
tag = f"cpython-{sys.version_info.major}{sys.version_info.minor}"
check50.include(f"{name}.{tag}.pyc")
rename(f"{name}.{tag}.pyc", f"{name}.pyc")
File renamed without changes.
Binary file added numb3rs/correct_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added numb3rs/first_byte_test.cpython-315.pyc
Binary file not shown.
Binary file added numb3rs/invalid_format_test.cpython-315.pyc
Binary file not shown.
18 changes: 16 additions & 2 deletions tests/bank/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import check50
import sys
from os import rename
from shutil import rmtree
from re import sub

Expand Down Expand Up @@ -52,7 +54,7 @@ def test_implementation(filename, code=0):
"""test an implementation of bank.py against student's checks in test_bank.py, expect a given exit status"""

# Include new compiled testing version of bank.py
check50.include(f"{filename}.pyc")
include_pyc(filename)

# Patch is_valid function from new test file
patch_file(f"{filename}")
Expand All @@ -62,4 +64,16 @@ def test_implementation(filename, code=0):
rmtree("__pycache__", ignore_errors=True)

# Expect that pytest will exit with given status code
return check50.run("pytest test_bank.py").exit(code=code)
return check50.run("pytest test_bank.py").exit(code=code)


def include_pyc(name):
"""Include name.pyc compiled for the running Python.

Bytecode is specific to a Python minor version: executing a mismatch crashes the
interpreter. The checks ship name.cpython-<major><minor>.pyc for each supported
version (from cs50/cs50p-pytest-tests); include the right one under the plain name.
"""
tag = f"cpython-{sys.version_info.major}{sys.version_info.minor}"
check50.include(f"{name}.{tag}.pyc")
rename(f"{name}.{tag}.pyc", f"{name}.pyc")
Binary file added tests/bank/case_sensitive_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added tests/bank/correct_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/bank/reversed_value_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/bank/starts_with_test.cpython-315.pyc
Binary file not shown.
16 changes: 15 additions & 1 deletion tests/fuel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import check50
import sys
from os import rename
from shutil import rmtree
from re import sub

Expand Down Expand Up @@ -82,7 +84,7 @@ def test_implementation(filename, code=0):
"""test an implementation of fuel.py against student's checks in test_fuel.py, expect a given exit status"""

# Include new compiled testing version of fuel.py
check50.include(f"{filename}.pyc")
include_pyc(filename)

# Patch is_valid function from new test file
patch_file(f"{filename}")
Expand All @@ -93,3 +95,15 @@ def test_implementation(filename, code=0):

# Expect that pytest will exit with given status code
return check50.run("pytest test_fuel.py").exit(code=code)


def include_pyc(name):
"""Include name.pyc compiled for the running Python.

Bytecode is specific to a Python minor version: executing a mismatch crashes the
interpreter. The checks ship name.cpython-<major><minor>.pyc for each supported
version (from cs50/cs50p-pytest-tests); include the right one under the plain name.
"""
tag = f"cpython-{sys.version_info.major}{sys.version_info.minor}"
check50.include(f"{name}.{tag}.pyc")
rename(f"{name}.{tag}.pyc", f"{name}.pyc")
File renamed without changes.
Binary file added tests/fuel/convert_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added tests/fuel/correct_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added tests/fuel/gauge_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/fuel/lower_bound_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/fuel/negative_fraction_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/fuel/percent_gauge_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/fuel/upper_bound_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/fuel/value_error_test.cpython-315.pyc
Binary file not shown.
Binary file not shown.
19 changes: 16 additions & 3 deletions tests/plates/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from distutils.filelist import findall
import check50
import sys
from os import rename
from shutil import rmtree
from re import sub, match

Expand Down Expand Up @@ -65,7 +66,7 @@ def test_implementation(filename, code=0):
"""test an implementation of plates.py against student's checks in test_plates.py, expect a given exit status"""

# Include new compiled testing version of plates.py
check50.include(f"{filename}.pyc")
include_pyc(filename)

# Patch is_valid function from new test file
patch_file(f"{filename}")
Expand All @@ -75,4 +76,16 @@ def test_implementation(filename, code=0):
rmtree("__pycache__", ignore_errors=True)

# Expect that pytest will exit with given status code
return check50.run("pytest test_plates.py").exit(code=code)
return check50.run("pytest test_plates.py").exit(code=code)


def include_pyc(name):
"""Include name.pyc compiled for the running Python.

Bytecode is specific to a Python minor version: executing a mismatch crashes the
interpreter. The checks ship name.cpython-<major><minor>.pyc for each supported
version (from cs50/cs50p-pytest-tests); include the right one under the plain name.
"""
tag = f"cpython-{sys.version_info.major}{sys.version_info.minor}"
check50.include(f"{name}.{tag}.pyc")
rename(f"{name}.{tag}.pyc", f"{name}.pyc")
File renamed without changes.
Binary file added tests/plates/alnum_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/plates/beginning_alpha_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/plates/correct_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added tests/plates/length_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added tests/plates/number_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added tests/plates/zero_test.cpython-315.pyc
Binary file not shown.
18 changes: 16 additions & 2 deletions tests/twttr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import check50
import sys
from os import rename
from shutil import rmtree
from re import sub

Expand Down Expand Up @@ -70,7 +72,7 @@ def test_implementation(filename, code=0):
"""test an implementation of twttr.py against student's checks in test_twttr.py, expect a given exit status"""

# Include new compiled testing version of twttr.py
check50.include(f"{filename}.pyc")
include_pyc(filename)

# Patch is_valid function from new test file
patch_file(f"{filename}")
Expand All @@ -80,4 +82,16 @@ def test_implementation(filename, code=0):
rmtree("__pycache__", ignore_errors=True)

# Expect that pytest will exit with given status code
return check50.run("pytest test_twttr.py").exit(code=code)
return check50.run("pytest test_twttr.py").exit(code=code)


def include_pyc(name):
"""Include name.pyc compiled for the running Python.

Bytecode is specific to a Python minor version: executing a mismatch crashes the
interpreter. The checks ship name.cpython-<major><minor>.pyc for each supported
version (from cs50/cs50p-pytest-tests); include the right one under the plain name.
"""
tag = f"cpython-{sys.version_info.major}{sys.version_info.minor}"
check50.include(f"{name}.{tag}.pyc")
rename(f"{name}.{tag}.pyc", f"{name}.pyc")
File renamed without changes.
Binary file added tests/twttr/capital_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/twttr/capital_vowel_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added tests/twttr/correct_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/twttr/lower_vowel_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added tests/twttr/number_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/twttr/punctuation_test.cpython-315.pyc
Binary file not shown.
Binary file added tests/twttr/vowel_replacement_test.cpython-315.pyc
Binary file not shown.
16 changes: 15 additions & 1 deletion um/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import check50
import sys
from os import rename
from shutil import rmtree
from re import escape, sub

Expand Down Expand Up @@ -103,7 +105,7 @@ def test_implementation(base_filename, implementation_filename, test_filename, c
"""Test implementation_file, an implementation of base_file, against student's checks in test_file. Expect a given exit status"""

check50.include("pytest_helper.py")
check50.include(implementation_filename)
include_pyc(implementation_filename.removesuffix(".pyc"))

# Overwrite base_file with code to run implementation_file
with open(base_filename, "w") as base_file, open("pytest_helper.py", "r") as pytest_helper:
Expand All @@ -123,3 +125,15 @@ def test_implementation(base_filename, implementation_filename, test_filename, c

# Expect that pytest will exit with given status code
return check50.run(f"pytest {test_filename}").exit(code=code)


def include_pyc(name):
"""Include name.pyc compiled for the running Python.

Bytecode is specific to a Python minor version: executing a mismatch crashes the
interpreter. The checks ship name.cpython-<major><minor>.pyc for each supported
version (from cs50/cs50p-pytest-tests); include the right one under the plain name.
"""
tag = f"cpython-{sys.version_info.major}{sys.version_info.minor}"
check50.include(f"{name}.{tag}.pyc")
rename(f"{name}.{tag}.pyc", f"{name}.pyc")
File renamed without changes.
Binary file added um/case_insensitive_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added um/correct_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added um/only_spaces_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added um/part_of_words_test.cpython-315.pyc
Binary file not shown.
16 changes: 15 additions & 1 deletion working/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import check50
import sys
from os import rename
from shutil import rmtree
from re import escape, search, sub

Expand Down Expand Up @@ -160,7 +162,7 @@ def test_implementation(base_filename, implementation_filename, test_filename, c
"""Test implementation_file, an implementation of base_file, against student's checks in test_file. Expect a given exit status"""

check50.include("pytest_helper.py")
check50.include(implementation_filename)
include_pyc(implementation_filename.removesuffix(".pyc"))

# Overwrite base_file with code to run implementation_file
with open(base_filename, "w") as base_file, open("pytest_helper.py", "r") as pytest_helper:
Expand All @@ -180,3 +182,15 @@ def test_implementation(base_filename, implementation_filename, test_filename, c

# Expect that pytest will exit with given status code
return check50.run(f"pytest {test_filename}").exit(code=code)


def include_pyc(name):
"""Include name.pyc compiled for the running Python.

Bytecode is specific to a Python minor version: executing a mismatch crashes the
interpreter. The checks ship name.cpython-<major><minor>.pyc for each supported
version (from cs50/cs50p-pytest-tests); include the right one under the plain name.
"""
tag = f"cpython-{sys.version_info.major}{sys.version_info.minor}"
check50.include(f"{name}.{tag}.pyc")
rename(f"{name}.{tag}.pyc", f"{name}.pyc")
File renamed without changes.
Binary file added working/correct_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added working/off_by_five_test.cpython-315.pyc
Binary file not shown.
File renamed without changes.
Binary file added working/off_by_one_test.cpython-315.pyc
Binary file not shown.
Binary file added working/raise_for_format_test.cpython-315.pyc
Binary file not shown.
Binary file not shown.