Skip to content

[Card Games]: Reformat lists_test.py by pylint to remove excess spaces. #2892

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

Merged
merged 6 commits into from
Feb 5, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
run: pip install dataclasses

- name: Install pytest
run: pip install pytest
run: pip install pytest~=6.2.5

- name: Check exercises
run: |
Expand Down
32 changes: 13 additions & 19 deletions exercises/concept/card-games/lists_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,35 @@ def test_get_rounds(self):

input_vars = [0, 1, 10, 27, 99, 666]

results = [[0, 1, 2], [1, 2, 3],
[10, 11, 12], [27, 28, 29],
results = [[0, 1, 2], [1, 2, 3],
[10, 11, 12], [27, 28, 29],
[99, 100, 101], [666, 667, 668]]

for variant, (number, rounds) in enumerate(zip(input_vars, results), start=1):
error_message = f'Expected rounds {rounds} given the current round {number}.'
with self.subTest(f'variation #{variant}', input=number, output=rounds):
self.assertEqual(rounds, get_rounds(number), msg=error_message)


@pytest.mark.task(taskno=2)
def test_concatenate_rounds(self):

input_vars = [([], []), ([0, 1], []), ([], [1, 2]),
([1], [2]), ([27, 28, 29], [35, 36]),
input_vars = [([], []), ([0, 1], []), ([], [1, 2]),
([1], [2]), ([27, 28, 29], [35, 36]),
([1, 2, 3], [4, 5, 6])]

results = [[], [0, 1], [1, 2], [1, 2],
[27, 28, 29, 35, 36],
results = [[], [0, 1], [1, 2], [1, 2],
[27, 28, 29, 35, 36],
[1, 2, 3, 4, 5, 6]]

for variant, ((rounds_1, rounds_2), rounds) in enumerate(zip(input_vars, results), start=1):
error_message = f'Expected {rounds} as the concatenation of {rounds_1} and {rounds_2}.'
with self.subTest(f'variation #{variant}', input=(rounds_1, rounds_2), output=rounds):
self.assertEqual(rounds, concatenate_rounds(rounds_1, rounds_2), msg=error_message)


@pytest.mark.task(taskno=3)
def test_list_contains_round(self):

input_vars = [([], 1), ([1, 2, 3], 0), ([27, 28, 29, 35, 36], 30),
input_vars = [([], 1), ([1, 2, 3], 0), ([27, 28, 29, 35, 36], 30),
([1], 1), ([1, 2, 3], 1), ([27, 28, 29, 35, 36], 29)]

results = [False, False, False, True, True, True]
Expand All @@ -58,7 +56,6 @@ def test_list_contains_round(self):
with self.subTest(f'variation #{variant}', input=(rounds, round_number), output=contains):
self.assertEqual(contains, list_contains_round(rounds, round_number), msg=error_message)


@pytest.mark.task(taskno=4)
def test_card_average(self):

Expand All @@ -67,11 +64,10 @@ def test_card_average(self):
results = [1.0, 6.0, 2.5, 37.0]

for variant, (hand, average) in enumerate(zip(input_vars, results), start=1):
error_message=f'Expected {average} as the average of {hand}.'
error_message = f'Expected {average} as the average of {hand}.'
with self.subTest(f'variation #{variant}', input=hand, output=average):
self.assertEqual(average, card_average(hand), msg=error_message)


@pytest.mark.task(taskno=5)
def test_approx_average_is_average(self):

Expand All @@ -86,7 +82,6 @@ def test_approx_average_is_average(self):
with self.subTest(f'variation #{variant}', input=hand, output=same):
self.assertEqual(same, approx_average_is_average(hand), msg=error_message)


@pytest.mark.task(taskno=6)
def test_average_even_is_average_odd(self):

Expand All @@ -95,19 +90,18 @@ def test_average_even_is_average_odd(self):
results = [False, False, True, True]

for variant, (hand, same) in enumerate(zip(input_vars, results), start=1):
error_message=f'Hand {hand} {"does" if same else "does not"} yield the same odd-even average.'
error_message = f'Hand {hand} {"does" if same else "does not"} yield the same odd-even average.'
with self.subTest(f'variation #{variant}', input=hand, output=same):
self.assertEqual(same, average_even_is_average_odd(hand),msg=error_message)

self.assertEqual(same, average_even_is_average_odd(hand), msg=error_message)

@pytest.mark.task(taskno=7)
def test_maybe_double_last(self):

input_vars = [[1, 2, 11], [5, 9, 11], [5, 9, 10], [1, 2, 3]]

results = [[1, 2, 22], [5, 9, 22], [5, 9 , 10], [1, 2, 3]]
results = [[1, 2, 22], [5, 9, 22], [5, 9, 10], [1, 2, 3]]

for variant, (hand, doubled_hand) in enumerate(zip(input_vars, results), start=1):
error_message=f'Expected {doubled_hand} as the maybe-doubled version of {hand}.'
error_message = f'Expected {doubled_hand} as the maybe-doubled version of {hand}.'
with self.subTest(f'variation #{variant}', input=hand, output=doubled_hand):
self.assertEqual(doubled_hand,maybe_double_last(hand),msg=error_message)
self.assertEqual(doubled_hand, maybe_double_last(hand), msg=error_message)