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
3 changes: 3 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
if: ${{ matrix.python-version == '3.6' }}
run: pip install dataclasses

- name: Install pytest
run: pip install pytest

- name: Check exercises
run: |
./bin/test_exercises.py
4 changes: 2 additions & 2 deletions bin/test_exercises.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def check_assignment(exercise: ExerciseInfo, quiet=False) -> int:
if quiet:
kwargs['stdout'] = subprocess.DEVNULL
kwargs['stderr'] = subprocess.DEVNULL
return subprocess.run([sys.executable, test_file_out], **kwargs).returncode
return subprocess.run([sys.executable, '-m', 'pytest', test_file_out], **kwargs).returncode
finally:
shutil.rmtree(workdir)

Expand All @@ -53,7 +53,7 @@ def main():
failures.append('{} (FileNotFound)'.format(exercise.slug))
else:
if check_assignment(exercise):
failures.append('{} (TestFailed)'.format(exercise))
failures.append('{} (TestFailed)'.format(exercise.slug))
print('')

print('TestEnvironment:', sys.executable.capitalize(), '\n\n')
Expand Down
4 changes: 2 additions & 2 deletions exercises/concept/currency-exchange/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
}
],
"files": {
"solution": ["numbers.py"],
"test": ["numbers_test.py"],
"solution": ["exchange.py"],
"test": ["exchange_test.py"],
"exemplar": [".meta/exemplar.py"]
}
}
2 changes: 1 addition & 1 deletion exercises/concept/currency-exchange/.meta/exemplar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def estimate_value(budget, exchange_rate):
return budget / exchange_rate


def get_changes(budget, exchanging_value):
def get_change(budget, exchanging_value):
return budget - exchanging_value


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_number_of_bills(budget, denomination):

def exchangeable_value(budget, exchange_rate, spread, minimum_denomination):
pass


def unexchangeable_value(budget, exchange_rate, spread, denomination):
pass
pass
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import unittest
from numbers import *
from exchange import *


class TestNumbers(unittest.TestCase):

# Problem 1
def test_estimate_value(self):
input_data = [
Expand Down Expand Up @@ -68,7 +68,7 @@ def test_exchangeable_value(self):
for input, output in zip(input_data, output_data):
with self.subTest(input=input, output=output):
self.assertEqual(exchangeable_value(input[0], input[1], input[2], input[3]), output)

# Problem 6
def test_unexchangeable_value(self):

Expand All @@ -87,5 +87,3 @@ def test_unexchangeable_value(self):
for input, output in zip(input_data, output_data):
with self.subTest(input=input, output=output):
self.assertEqual(unexchangeable_value(input[0], input[1], input[2], input[3]), output)


12 changes: 6 additions & 6 deletions exercises/concept/making-the-grade/.meta/exemplar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ def count_failed_students(student_marks):
failed_marks = 0
for mark in student_marks:
if mark <=40:
failed_marks +=1
failed_marks += 1
return failed_marks

def above_threshold(student_marks, x):
above_marks = []
for mark in student_marks:
if mark < x:
continue
above_marks.append(mark)
if mark >= x:
above_marks.append(mark)
return above_marks

def first_k_student_marks(student_marks, k):
i = 0
marks = []
while i <= k:
while i < k:
marks.append(student_marks[i])
i += 1
return marks

def perfect_score(student_info):
for name, mark in student_info.items():
if mark == 100:
return name
else:
return "No hundreds"
return "No Centums"