Skip to content

Commit

Permalink
# Pull your words together, man
Browse files Browse the repository at this point in the history
  • Loading branch information
ikostan committed Dec 20, 2024
1 parent 9086ad3 commit 0518e84
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion kyu_7/pull_your_words_together_man/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ it in normal English orthography, it just outputs a list of words.

Robbie has pulled multiple all-nighters to get this project finished,
and he needs some beauty sleep. So, he wants you to write the last part
of his code, a sentencify function, which takes the output that the
of his code, a `sentencify` function, which takes the output that the
machine gives, and formats it into proper English orthography.

**Your function should:**
Expand Down
1 change: 1 addition & 0 deletions kyu_7/pull_your_words_together_man/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Pull your words together, man."""
6 changes: 4 additions & 2 deletions kyu_7/pull_your_words_together_man/sentencify.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
"""
Solution for -> Pull your words together, man!
Solution for -> Pull your words together, man!.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""


def sentencify(words: list) -> str:
"""
'Sentencify' function.
The function should:
1. Capitalise the first letter of the first word.
2. Add a period (.) to the end of the sentence.
3. Join the words into a complete string, with spaces.
4. Do no other manipulation on the words.
:param words: list
:return: str
"""
Expand Down
45 changes: 20 additions & 25 deletions kyu_7/pull_your_words_together_man/test_sentencify.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Test for -> Pull your words together, man!
Test for -> Pull your words together, man!.
Created by Egor Kostan.
GitHub: https://github.com/ikostan
"""
Expand All @@ -8,6 +9,7 @@

import unittest
import allure
from parameterized import parameterized
from utils.log_func import print_log
from kyu_7.pull_your_words_together_man.sentencify import sentencify

Expand All @@ -27,19 +29,26 @@
name='Source/Kata')
# pylint: enable-msg=R0801
class SentencifyTestCase(unittest.TestCase):
"""
Testing 'sentencify' function
"""
"""Testing 'sentencify' function."""

def test_sentencify(self):
@parameterized.expand([
(["i", "am", "an", "AI"],
"I am an AI."),
(["yes"],
"Yes."),
(["FIELDS", "of", "CORN", "are", "to", "be", "sown"],
"FIELDS of CORN are to be sown."),
(["i'm", "afraid", "I", "can't", "let", "you", "do", "that"],
"I'm afraid I can't let you do that.")])
def test_sentencify(self, words, expected):
"""
Testing 'sentencify' function.
Testing 'sentencify' function with various test data.
The function should:
1. Capitalise the first letter of the first word.
2. Add a period (.) to the end of the sentence.
3. Join the words into a complete string, with spaces.
4. Do no other manipulation on the words.
:return:
"""
# pylint: disable-msg=R0801
Expand All @@ -52,21 +61,7 @@ def test_sentencify(self):
'<h3>Test Description:</h3>'
"<p></p>")
# pylint: enable-msg=R0801
with allure.step("Enter a list of strings"
" and verify the result"):
test_data = [
(["i", "am", "an", "AI"],
"I am an AI."),
(["yes"],
"Yes."),
(["FIELDS", "of", "CORN", "are", "to", "be", "sown"],
"FIELDS of CORN are to be sown."),
(["i'm", "afraid", "I", "can't", "let", "you", "do", "that"],
"I'm afraid I can't let you do that.")]

for words, expected in test_data:
print_log(expected=expected,
words=words)

self.assertEqual(expected,
sentencify(words))
with allure.step(f"Enter a list of strings: {words}"
f" and verify the expected result: {expected}."):
print_log(expected=expected, words=words)
self.assertEqual(expected, sentencify(words))

0 comments on commit 0518e84

Please sign in to comment.