From 420aabab1fd071b01136ed566c52ddcd8abcfe9c Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Fri, 10 Jan 2025 08:59:03 +0100 Subject: [PATCH 01/15] Fixed test_count_vowels directory issuues --- .vscode/settings.json | 15 ++++++++++++++- solutions/tests/test_count_vowels.py | 4 ++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 20b19131b..0667abd28 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -123,5 +123,18 @@ "source.organizeImports.ruff": "explicit" } }, - "cSpell.words": ["doctests", "Hussaini", "Pylint"] + "cSpell.words": [ + "doctests", + "Hussaini", + "Pylint" + ], + "python.testing.unittestArgs": [ + "-v", + "-s", + ".", + "-p", + "test_*.py" + ], + "python.testing.pytestEnabled": false, + "python.testing.unittestEnabled": true } diff --git a/solutions/tests/test_count_vowels.py b/solutions/tests/test_count_vowels.py index c52ec8633..09896f86f 100644 --- a/solutions/tests/test_count_vowels.py +++ b/solutions/tests/test_count_vowels.py @@ -1,6 +1,6 @@ import unittest -from count_vowels import count_vowels +from ..count_vowels import count_vowels class TestCountVowels(unittest.TestCase): @@ -26,7 +26,7 @@ def test_numeric_and_special_characters(self): def test_vowels_in_words(self): """Test a string with words containing vowels.""" - self.assertEqual(count_vowels("Python programming is fun!"), 8) + self.assertEqual(count_vowels("Python programming is fun!"), 6) if __name__ == "__main__": From c4efedc526132c5d4c881c9880ffcd4040cdd7dd Mon Sep 17 00:00:00 2001 From: Noorelsalam Almakki Date: Sat, 11 Jan 2025 19:46:59 +0100 Subject: [PATCH 02/15] Delete .vscode/settings.json --- .vscode/settings.json | 140 ------------------------------------------ 1 file changed, 140 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 0667abd28..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,140 +0,0 @@ -{ - // https://vscode-docs.readthedocs.io/en/stable/customization/userandworkspace/#default-settings - //-------- Editor configuration -------- - - // Controls auto save of editors that have unsaved changes.: https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save - "files.autoSave": "onFocusChange", - - // Format a file on save. A formatter must be available. - "editor.formatOnSave": true, - - // Controls whether the editor should automatically format the pasted content. A formatter must be available. - "editor.formatOnPaste": true, - - // Controls whether the editor should render indent quides - "editor.guides.indentation": true, - - // Controls whether the editor should highlight the active indent guide. - "editor.guides.highlightActiveIndentation": true, - - // Controls the rendering size of tabs in characters. Accepted values: "auto", 2, 4, 6, etc. If set to "auto", the value will be guessed when a file is opened. - "editor.tabSize": 2, - - // Defines a default formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter - "editor.defaultFormatter": "esbenp.prettier-vscode", - - // Controls bracket pair colorization is enabled or not - "editor.bracketPairColorization.enabled": true, - - // Controls whether bracket pair guides are enabled or not. (true, active, false) - "editor.guides.bracketPairs": "active", - - // Controls whether horizontal bracket pair guides are enabled or not. - "editor.guides.bracketPairsHorizontal": "active", - - // Controls whether the editor should highlight the active bracket pair. - "editor.guides.highlightActiveBracketPair": true, - - // Controls whether the editor has linked editing enabled. - "editor.linkedEditing": true, - - //-------- HTML configuration -------- - - // Enable/disable auto closing of HTML tags - "html.autoClosingTags": true, - - // Configures if the built-in HTML language suggests HTML5 tags, properties and values. - "html.suggest.html5": true, - - // Defines a default HTML formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter - "[html]": { - "editor.defaultFormatter": "vscode.html-language-features" - }, - - //-------- Emmet configuration -------- - - // Enables completion when you are writing Emmet appreveation. - "html-css-class-completion.enableEmmetSupport": true, - - //-------- JavaScript configuration -------- - - // Enable/disable auto closing of JSX tags. - "javascript.autoClosingTags": true, - - // Enable/disable auto import suggestions. - "javascript.suggest.autoImports": true, - - // Enable/disable automatic updating of import paths when you rename or move a file in VS Code. - "javascript.updateImportsOnFileMove.enabled": "always", - - // Enable/disable suggestoins for paths in import statement and require calls. (change it to false to be able to use Path Intellisense extension) - "javascript.suggest.paths": false, - - //-------- TypeScript configuration -------- - - // Enable/disable auto closing of JSX tags. - "typescript.autoClosingTags": true, - - // Enable/disable auto import suggestions. - "typescript.suggest.autoImports": true, - - // Enable/disable automatic updating of import paths when you rename or move a file in VS Code. - "typescript.updateImportsOnFileMove.enabled": "always", - - // Enable/disable suggestoins for paths in import statement and require calls. (change it to false to be able to use Path Intellisense extension) - "typescript.suggest.paths": false, - - //-------- Work Bench configuration -------- - - // Controls whether a top border is drawn on tabs for editors that have unsaved changes. - "workbench.editor.highlightModifiedTabs": true, - - //-------- Files configuration -------- - - // When enabled, will trim all new lines after the final new line at the end of the file when saving it. - "files.trimFinalNewlines": true, - - // When enabled, insert a new final line at the end of the file when saving it. - "files.insertFinalNewline": true, - - //-------- Live Server configuration -------- - - // Set Custom Port Number of Live Server. Set 0 if you want random port. - "liveServer.settings.port": 5504, - - //-------- Markdown configuration -------- - - // Enable path suggestoins while writing links in markdown files - "markdown.suggest.paths.enabled": true, - - // Defines a default markdown formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter - "[markdown]": { - "editor.defaultFormatter": "DavidAnson.vscode-markdownlint" - }, - - // Enable/disable update table of contents on save - "markdown.extension.toc.updateOnSave": false, - - "[python]": { - "editor.defaultFormatter": "charliermarsh.ruff", - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.fixAll.ruff": "explicit", - "source.organizeImports.ruff": "explicit" - } - }, - "cSpell.words": [ - "doctests", - "Hussaini", - "Pylint" - ], - "python.testing.unittestArgs": [ - "-v", - "-s", - ".", - "-p", - "test_*.py" - ], - "python.testing.pytestEnabled": false, - "python.testing.unittestEnabled": true -} From a8fa669bf80e682d3ed3d93c772ebe2f8bba8734 Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sat, 11 Jan 2025 22:25:42 +0100 Subject: [PATCH 03/15] Added class docstring --- solutions/tests/test_count_vowels.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/solutions/tests/test_count_vowels.py b/solutions/tests/test_count_vowels.py index 09896f86f..fc2fade99 100644 --- a/solutions/tests/test_count_vowels.py +++ b/solutions/tests/test_count_vowels.py @@ -4,6 +4,8 @@ class TestCountVowels(unittest.TestCase): + """A class to test the number of vowels in a given string""" + def test_empty_string(self): """Test that an empty string returns 0.""" self.assertEqual(count_vowels(""), 0) From 2f5ab1bdf77128e4a535035267f3ea70571006d7 Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sat, 11 Jan 2025 22:43:27 +0100 Subject: [PATCH 04/15] Update solutions/count_vowels.py Module header Co-authored-by: Noorelsalam Almakki --- solutions/count_vowels.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/solutions/count_vowels.py b/solutions/count_vowels.py index 6b98c023f..dae5b6e9c 100644 --- a/solutions/count_vowels.py +++ b/solutions/count_vowels.py @@ -1,4 +1,14 @@ -def count_vowels(input_string): +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +A module for calculating the + +Module contents: + - : . + +Created on +@author: +""" """ Counts the number of vowels in a given string. From a2a1387616c5e1a74977cf4a21ff0b16c1e2ebdf Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sat, 11 Jan 2025 23:16:13 +0100 Subject: [PATCH 05/15] Corrections and chages made to the code --- solutions/count_vowels.py | 17 +++++++--- solutions/tests/test_count_vowels.py | 47 ++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/solutions/count_vowels.py b/solutions/count_vowels.py index dae5b6e9c..b906068c1 100644 --- a/solutions/count_vowels.py +++ b/solutions/count_vowels.py @@ -1,14 +1,16 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -A module for calculating the +A module for calculating the number of vowels in a given string. Module contents: - - : . + - count_vowels: Counts the number of vowels (a, e, i, o, u) in a string. Created on @author: """ + +def count_vowels(input_string): """ Counts the number of vowels in a given string. @@ -19,11 +21,17 @@ int: The total number of vowels (a, e, i, o, u) in the string, including both uppercase and lowercase vowels. - Example: + Examples: >>> count_vowels("Hello, World!") 3 >>> count_vowels("Python") 1 + >>> count_vowels("AEIOU") + 5 + >>> count_vowels("The quick brown fox.") + 5 + >>> count_vowels("BCDFG") + 0 """ vowels = "aeiouAEIOU" # List of vowels (both uppercase and lowercase) count = 0 @@ -32,8 +40,7 @@ count += 1 return count - # Example usage if __name__ == "__main__": input_string = "Hello, how many vowels are here?" - print("Number of vowels:", count_vowels(input_string)) + print("Number of vowels:", count_vowels(input_string)) \ No newline at end of file diff --git a/solutions/tests/test_count_vowels.py b/solutions/tests/test_count_vowels.py index fc2fade99..4216f0c77 100644 --- a/solutions/tests/test_count_vowels.py +++ b/solutions/tests/test_count_vowels.py @@ -1,10 +1,24 @@ -import unittest +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Module: test_count_vowels +Description: This module contains unit tests for the `count_vowels` function. + +The `count_vowels` function takes a string as input and counts the number of vowels +(a, e, i, o, u) in the string, including both uppercase and lowercase vowels. + +This module uses the `unittest` framework to test various cases for correctness. +Author: +Created on: +""" + +import unittest from ..count_vowels import count_vowels class TestCountVowels(unittest.TestCase): - """A class to test the number of vowels in a given string""" + """A class to test the number of vowels in a given string.""" def test_empty_string(self): """Test that an empty string returns 0.""" @@ -31,5 +45,32 @@ def test_vowels_in_words(self): self.assertEqual(count_vowels("Python programming is fun!"), 6) +# Updated count_vowels function with input validation +def count_vowels(input_string): + """ + Counts the number of vowels in a given string. + + Args: + input_string (str): The string to analyze for vowels. + + Returns: + int: The total number of vowels (a, e, i, o, u) in the string, + including both uppercase and lowercase vowels. + + Raises: + TypeError: If the input is not a string. + """ + # Ensure input is a string + if not isinstance(input_string, str): + raise TypeError("Input must be a string.") + + vowels = "aeiouAEIOU" # List of vowels (both uppercase and lowercase) + count = 0 + for char in input_string: + if char in vowels: + count += 1 + return count + + if __name__ == "__main__": - unittest.main() + unittest.main() \ No newline at end of file From 1f4854915a212fe372b1320e441b76d772331176 Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sat, 11 Jan 2025 23:28:25 +0100 Subject: [PATCH 06/15] fixing py_formatting error --- solutions/tests/test_count_vowels.py | 30 +--------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/solutions/tests/test_count_vowels.py b/solutions/tests/test_count_vowels.py index 4216f0c77..29d893f47 100644 --- a/solutions/tests/test_count_vowels.py +++ b/solutions/tests/test_count_vowels.py @@ -14,7 +14,7 @@ """ import unittest -from ..count_vowels import count_vowels +from solutions.count_vowels import count_vowels class TestCountVowels(unittest.TestCase): @@ -44,33 +44,5 @@ def test_vowels_in_words(self): """Test a string with words containing vowels.""" self.assertEqual(count_vowels("Python programming is fun!"), 6) - -# Updated count_vowels function with input validation -def count_vowels(input_string): - """ - Counts the number of vowels in a given string. - - Args: - input_string (str): The string to analyze for vowels. - - Returns: - int: The total number of vowels (a, e, i, o, u) in the string, - including both uppercase and lowercase vowels. - - Raises: - TypeError: If the input is not a string. - """ - # Ensure input is a string - if not isinstance(input_string, str): - raise TypeError("Input must be a string.") - - vowels = "aeiouAEIOU" # List of vowels (both uppercase and lowercase) - count = 0 - for char in input_string: - if char in vowels: - count += 1 - return count - - if __name__ == "__main__": unittest.main() \ No newline at end of file From 565645f3c31faafed69458faeac55d2b9de7a8ca Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sat, 11 Jan 2025 23:36:04 +0100 Subject: [PATCH 07/15] Py_formattting error fix --- solutions/count_vowels.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/solutions/count_vowels.py b/solutions/count_vowels.py index b906068c1..d296340b6 100644 --- a/solutions/count_vowels.py +++ b/solutions/count_vowels.py @@ -1,13 +1,18 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -A module for calculating the number of vowels in a given string. +Module: count_vowels +Description: A module for calculating the number of vowels in a given string. -Module contents: - - count_vowels: Counts the number of vowels (a, e, i, o, u) in a string. +This module contains the following: + - count_vowels: A function to count the total number of vowels in a string. -Created on -@author: +Features: + - Counts both uppercase and lowercase vowels (a, e, i, o, u). + - Provides example usage in the function docstring. + +Created on: +Author: """ def count_vowels(input_string): @@ -19,7 +24,7 @@ def count_vowels(input_string): Returns: int: The total number of vowels (a, e, i, o, u) in the string, - including both uppercase and lowercase vowels. + including both uppercase and lowercase vowels. Examples: >>> count_vowels("Hello, World!") From c3fcbbb6a94c8f26cf1aef4df55af6a9faa40134 Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sat, 11 Jan 2025 23:58:44 +0100 Subject: [PATCH 08/15] Py_formatting 3 --- solutions/count_vowels.py | 2 +- solutions/tests/test_count_vowels.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/solutions/count_vowels.py b/solutions/count_vowels.py index d296340b6..6c58df5e1 100644 --- a/solutions/count_vowels.py +++ b/solutions/count_vowels.py @@ -24,7 +24,7 @@ def count_vowels(input_string): Returns: int: The total number of vowels (a, e, i, o, u) in the string, - including both uppercase and lowercase vowels. + including both uppercase and lowercase vowels. Examples: >>> count_vowels("Hello, World!") diff --git a/solutions/tests/test_count_vowels.py b/solutions/tests/test_count_vowels.py index 29d893f47..e71c5af0e 100644 --- a/solutions/tests/test_count_vowels.py +++ b/solutions/tests/test_count_vowels.py @@ -43,6 +43,6 @@ def test_numeric_and_special_characters(self): def test_vowels_in_words(self): """Test a string with words containing vowels.""" self.assertEqual(count_vowels("Python programming is fun!"), 6) - -if __name__ == "__main__": - unittest.main() \ No newline at end of file + + if __name__ == "__main__": + unittest.main() \ No newline at end of file From 0ea3dcbcb1df9f2dd19496472daa0e923cf049db Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sun, 12 Jan 2025 10:01:52 +0100 Subject: [PATCH 09/15] Reworking Py_formatting issues --- solutions/count_vowels.py | 51 ---------------------------- solutions/tests/test_count_vowels.py | 49 +++++++++++++++----------- 2 files changed, 29 insertions(+), 71 deletions(-) diff --git a/solutions/count_vowels.py b/solutions/count_vowels.py index 6c58df5e1..e69de29bb 100644 --- a/solutions/count_vowels.py +++ b/solutions/count_vowels.py @@ -1,51 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -""" -Module: count_vowels -Description: A module for calculating the number of vowels in a given string. - -This module contains the following: - - count_vowels: A function to count the total number of vowels in a string. - -Features: - - Counts both uppercase and lowercase vowels (a, e, i, o, u). - - Provides example usage in the function docstring. - -Created on: -Author: -""" - -def count_vowels(input_string): - """ - Counts the number of vowels in a given string. - - Args: - input_string (str): The string to analyze for vowels. - - Returns: - int: The total number of vowels (a, e, i, o, u) in the string, - including both uppercase and lowercase vowels. - - Examples: - >>> count_vowels("Hello, World!") - 3 - >>> count_vowels("Python") - 1 - >>> count_vowels("AEIOU") - 5 - >>> count_vowels("The quick brown fox.") - 5 - >>> count_vowels("BCDFG") - 0 - """ - vowels = "aeiouAEIOU" # List of vowels (both uppercase and lowercase) - count = 0 - for char in input_string: - if char in vowels: - count += 1 - return count - -# Example usage -if __name__ == "__main__": - input_string = "Hello, how many vowels are here?" - print("Number of vowels:", count_vowels(input_string)) \ No newline at end of file diff --git a/solutions/tests/test_count_vowels.py b/solutions/tests/test_count_vowels.py index e71c5af0e..fc1944fad 100644 --- a/solutions/tests/test_count_vowels.py +++ b/solutions/tests/test_count_vowels.py @@ -1,48 +1,57 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ -Module: test_count_vowels -Description: This module contains unit tests for the `count_vowels` function. +A module for testing the count_vowels function. -The `count_vowels` function takes a string as input and counts the number of vowels -(a, e, i, o, u) in the string, including both uppercase and lowercase vowels. - -This module uses the `unittest` framework to test various cases for correctness. - -Author: -Created on: +Created on 01 Jan 2025 +@author: Daniel Oluwaluyi """ import unittest -from solutions.count_vowels import count_vowels +from ..count_vowels import count_vowels class TestCountVowels(unittest.TestCase): - """A class to test the number of vowels in a given string.""" + """A class for testing the count_vowels function.""" def test_empty_string(self): - """Test that an empty string returns 0.""" + """Test the count_vowels function with an empty string.""" self.assertEqual(count_vowels(""), 0) def test_no_vowels(self): - """Test a string with no vowels.""" + """Test the count_vowels function with a string containing no vowels.""" self.assertEqual(count_vowels("bcdfghjklmnpqrstvwxyz"), 0) def test_all_vowels(self): - """Test a string with all vowels (lowercase and uppercase).""" + """Test the count_vowels function with a string containing all vowels (lowercase and uppercase).""" self.assertEqual(count_vowels("aeiouAEIOU"), 10) def test_mixed_string(self): - """Test a string with a mix of vowels and consonants.""" + """Test the count_vowels function with a string containing both vowels and consonants.""" self.assertEqual(count_vowels("Hello, World!"), 3) def test_numeric_and_special_characters(self): - """Test a string with numbers and special characters.""" + """Test the count_vowels function with a string containing numbers and special characters.""" self.assertEqual(count_vowels("12345!@#$%^&*()"), 0) def test_vowels_in_words(self): - """Test a string with words containing vowels.""" + """Test the count_vowels function with a string containing multiple words with vowels.""" self.assertEqual(count_vowels("Python programming is fun!"), 6) - - if __name__ == "__main__": - unittest.main() \ No newline at end of file + + def test_only_whitespace(self): + """Test the count_vowels function with a string containing only whitespace.""" + self.assertEqual(count_vowels(" "), 0) + + def test_string_with_newline(self): + """Test the count_vowels function with a string containing a newline character.""" + self.assertEqual(count_vowels("Hello\nWorld"), 3) + + def test_non_string_input(self): + """Test the count_vowels function with a non-string input.""" + with self.assertRaises(AssertionError): + count_vowels(123) + + +# Run tests if the module is executed directly +if __name__ == "__main__": + unittest.main() \ No newline at end of file From 88bae8fed23c46ab49ddf90194360851530738b5 Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sun, 12 Jan 2025 10:13:09 +0100 Subject: [PATCH 10/15] Modification to codes --- solutions/count_vowels.py | 46 ++++++++++++++++++++++++++++ solutions/tests/test_count_vowels.py | 23 ++++++-------- 2 files changed, 55 insertions(+), 14 deletions(-) diff --git a/solutions/count_vowels.py b/solutions/count_vowels.py index e69de29bb..531f30da8 100644 --- a/solutions/count_vowels.py +++ b/solutions/count_vowels.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +A module for counting the number of vowels in a given string. + +Created on 01 Jan 2025 +@author: Daniel Oluwaluyi +""" + + +def count_vowels(input_string: str) -> int: + """ + Count the number of vowels in the provided string. + + This function takes a string as input and counts the occurrences + of vowels (a, e, i, o, u), including both lowercase and uppercase letters. + + Args: + input_string (str): The input string to process. + + Returns: + int: The count of vowels in the input string. + + Raises: + AssertionError: If the input is not a string. + + Doctests: + >>> count_vowels("hello") + 2 + >>> count_vowels("HELLO") + 2 + >>> count_vowels("12345!@#$%^&*()") + 0 + >>> count_vowels("aeiouAEIOU") + 10 + >>> count_vowels("") + 0 + """ + # Defensive assertion to ensure the input is a string + assert isinstance(input_string, str), "Input must be a string" + + # Define a set of vowels for quick lookup + vowels = set("aeiouAEIOU") + + # Count and return the number of vowels in the string + return sum(1 for char in input_string if char in vowels) diff --git a/solutions/tests/test_count_vowels.py b/solutions/tests/test_count_vowels.py index fc1944fad..073ffab32 100644 --- a/solutions/tests/test_count_vowels.py +++ b/solutions/tests/test_count_vowels.py @@ -8,7 +8,7 @@ """ import unittest -from ..count_vowels import count_vowels +from solutions.count_vowels import count_vowels class TestCountVowels(unittest.TestCase): @@ -23,11 +23,11 @@ def test_no_vowels(self): self.assertEqual(count_vowels("bcdfghjklmnpqrstvwxyz"), 0) def test_all_vowels(self): - """Test the count_vowels function with a string containing all vowels (lowercase and uppercase).""" + """Test the count_vowels function with a string containing all vowels.""" self.assertEqual(count_vowels("aeiouAEIOU"), 10) def test_mixed_string(self): - """Test the count_vowels function with a string containing both vowels and consonants.""" + """Test the count_vowels function with a string containing vowels and consonants.""" self.assertEqual(count_vowels("Hello, World!"), 3) def test_numeric_and_special_characters(self): @@ -35,23 +35,18 @@ def test_numeric_and_special_characters(self): self.assertEqual(count_vowels("12345!@#$%^&*()"), 0) def test_vowels_in_words(self): - """Test the count_vowels function with a string containing multiple words with vowels.""" + """Test the count_vowels function with a string containing multiple words.""" self.assertEqual(count_vowels("Python programming is fun!"), 6) - def test_only_whitespace(self): - """Test the count_vowels function with a string containing only whitespace.""" - self.assertEqual(count_vowels(" "), 0) - - def test_string_with_newline(self): - """Test the count_vowels function with a string containing a newline character.""" - self.assertEqual(count_vowels("Hello\nWorld"), 3) + def test_string_with_whitespace(self): + """Test the count_vowels function with a string containing leading and trailing whitespace.""" + self.assertEqual(count_vowels(" aeiou "), 5) def test_non_string_input(self): """Test the count_vowels function with a non-string input.""" with self.assertRaises(AssertionError): - count_vowels(123) + count_vowels(12345) -# Run tests if the module is executed directly if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() From c1de8a2d7a28ff2c4ea921d7924c57cb1f9d2998 Mon Sep 17 00:00:00 2001 From: Noorelsalam Almakki Date: Sun, 12 Jan 2025 10:48:51 +0000 Subject: [PATCH 11/15] Fixed formating error --- solutions/count_vowels.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solutions/count_vowels.py b/solutions/count_vowels.py index 531f30da8..2ab9cfef1 100644 --- a/solutions/count_vowels.py +++ b/solutions/count_vowels.py @@ -41,6 +41,6 @@ def count_vowels(input_string: str) -> int: # Define a set of vowels for quick lookup vowels = set("aeiouAEIOU") - + # Count and return the number of vowels in the string return sum(1 for char in input_string if char in vowels) From 8f01ec710c5e1505d32d9f1a699f9850f57296a0 Mon Sep 17 00:00:00 2001 From: Noorelsalam Almakki Date: Sun, 12 Jan 2025 10:58:11 +0000 Subject: [PATCH 12/15] Resolved settings.json file conflict --- .vscode/settings.json | 126 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..15aa21805 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,126 @@ +{ + // https://vscode-docs.readthedocs.io/en/stable/customization/userandworkspace/#default-settings + //-------- Editor configuration -------- + + // Controls auto save of editors that have unsaved changes.: https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save + "files.autoSave": "onFocusChange", + + // Format a file on save. A formatter must be available. + "editor.formatOnSave": true, + + // Controls whether the editor should automatically format the pasted content. A formatter must be available. + "editor.formatOnPaste": true, + + // Controls whether the editor should render indent quides + "editor.guides.indentation": true, + + // Controls whether the editor should highlight the active indent guide. + "editor.guides.highlightActiveIndentation": true, + + // Controls the rendering size of tabs in characters. Accepted values: "auto", 2, 4, 6, etc. If set to "auto", the value will be guessed when a file is opened. + "editor.tabSize": 2, + + // Defines a default formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter + "editor.defaultFormatter": "esbenp.prettier-vscode", + + // Controls bracket pair colorization is enabled or not + "editor.bracketPairColorization.enabled": true, + + // Controls whether bracket pair guides are enabled or not. (true, active, false) + "editor.guides.bracketPairs": "active", + + // Controls whether horizontal bracket pair guides are enabled or not. + "editor.guides.bracketPairsHorizontal": "active", + + // Controls whether the editor should highlight the active bracket pair. + "editor.guides.highlightActiveBracketPair": true, + + // Controls whether the editor has linked editing enabled. + "editor.linkedEditing": true, + + //-------- HTML configuration -------- + + // Enable/disable auto closing of HTML tags + "html.autoClosingTags": true, + + // Configures if the built-in HTML language suggests HTML5 tags, properties and values. + "html.suggest.html5": true, + + // Defines a default HTML formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter + "[html]": { + "editor.defaultFormatter": "vscode.html-language-features" + }, + + //-------- Emmet configuration -------- + + // Enables completion when you are writing Emmet appreveation. + "html-css-class-completion.enableEmmetSupport": true, + + //-------- JavaScript configuration -------- + + // Enable/disable auto closing of JSX tags. + "javascript.autoClosingTags": true, + + // Enable/disable auto import suggestions. + "javascript.suggest.autoImports": true, + + // Enable/disable automatic updating of import paths when you rename or move a file in VS Code. + "javascript.updateImportsOnFileMove.enabled": "always", + + // Enable/disable suggestoins for paths in import statement and require calls. (change it to false to be able to use Path Intellisense extension) + "javascript.suggest.paths": false, + + //-------- TypeScript configuration -------- + + // Enable/disable auto closing of JSX tags. + "typescript.autoClosingTags": true, + + // Enable/disable auto import suggestions. + "typescript.suggest.autoImports": true, + + // Enable/disable automatic updating of import paths when you rename or move a file in VS Code. + "typescript.updateImportsOnFileMove.enabled": "always", + + // Enable/disable suggestoins for paths in import statement and require calls. (change it to false to be able to use Path Intellisense extension) + "typescript.suggest.paths": false, + + //-------- Work Bench configuration -------- + + // Controls whether a top border is drawn on tabs for editors that have unsaved changes. + "workbench.editor.highlightModifiedTabs": true, + + //-------- Files configuration -------- + + // When enabled, will trim all new lines after the final new line at the end of the file when saving it. + "files.trimFinalNewlines": true, + + // When enabled, insert a new final line at the end of the file when saving it. + "files.insertFinalNewline": true, + + //-------- Live Server configuration -------- + + // Set Custom Port Number of Live Server. Set 0 if you want random port. + "liveServer.settings.port": 5504, + + //-------- Markdown configuration -------- + + // Enable path suggestoins while writing links in markdown files + "markdown.suggest.paths.enabled": true, + + // Defines a default markdown formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter + "[markdown]": { + "editor.defaultFormatter": "DavidAnson.vscode-markdownlint" + }, + + // Enable/disable update table of contents on save + "markdown.extension.toc.updateOnSave": false, + + "[python]": { + "editor.defaultFormatter": "charliermarsh.ruff", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.ruff": "explicit", + "source.organizeImports.ruff": "explicit" + } + } +} From 834e62b773baa06094db5529462b855a922fffef Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sun, 12 Jan 2025 14:59:52 +0100 Subject: [PATCH 13/15] Delete .vscode/settings.json --- .vscode/settings.json | 126 ------------------------------------------ 1 file changed, 126 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 15aa21805..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - // https://vscode-docs.readthedocs.io/en/stable/customization/userandworkspace/#default-settings - //-------- Editor configuration -------- - - // Controls auto save of editors that have unsaved changes.: https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save - "files.autoSave": "onFocusChange", - - // Format a file on save. A formatter must be available. - "editor.formatOnSave": true, - - // Controls whether the editor should automatically format the pasted content. A formatter must be available. - "editor.formatOnPaste": true, - - // Controls whether the editor should render indent quides - "editor.guides.indentation": true, - - // Controls whether the editor should highlight the active indent guide. - "editor.guides.highlightActiveIndentation": true, - - // Controls the rendering size of tabs in characters. Accepted values: "auto", 2, 4, 6, etc. If set to "auto", the value will be guessed when a file is opened. - "editor.tabSize": 2, - - // Defines a default formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter - "editor.defaultFormatter": "esbenp.prettier-vscode", - - // Controls bracket pair colorization is enabled or not - "editor.bracketPairColorization.enabled": true, - - // Controls whether bracket pair guides are enabled or not. (true, active, false) - "editor.guides.bracketPairs": "active", - - // Controls whether horizontal bracket pair guides are enabled or not. - "editor.guides.bracketPairsHorizontal": "active", - - // Controls whether the editor should highlight the active bracket pair. - "editor.guides.highlightActiveBracketPair": true, - - // Controls whether the editor has linked editing enabled. - "editor.linkedEditing": true, - - //-------- HTML configuration -------- - - // Enable/disable auto closing of HTML tags - "html.autoClosingTags": true, - - // Configures if the built-in HTML language suggests HTML5 tags, properties and values. - "html.suggest.html5": true, - - // Defines a default HTML formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter - "[html]": { - "editor.defaultFormatter": "vscode.html-language-features" - }, - - //-------- Emmet configuration -------- - - // Enables completion when you are writing Emmet appreveation. - "html-css-class-completion.enableEmmetSupport": true, - - //-------- JavaScript configuration -------- - - // Enable/disable auto closing of JSX tags. - "javascript.autoClosingTags": true, - - // Enable/disable auto import suggestions. - "javascript.suggest.autoImports": true, - - // Enable/disable automatic updating of import paths when you rename or move a file in VS Code. - "javascript.updateImportsOnFileMove.enabled": "always", - - // Enable/disable suggestoins for paths in import statement and require calls. (change it to false to be able to use Path Intellisense extension) - "javascript.suggest.paths": false, - - //-------- TypeScript configuration -------- - - // Enable/disable auto closing of JSX tags. - "typescript.autoClosingTags": true, - - // Enable/disable auto import suggestions. - "typescript.suggest.autoImports": true, - - // Enable/disable automatic updating of import paths when you rename or move a file in VS Code. - "typescript.updateImportsOnFileMove.enabled": "always", - - // Enable/disable suggestoins for paths in import statement and require calls. (change it to false to be able to use Path Intellisense extension) - "typescript.suggest.paths": false, - - //-------- Work Bench configuration -------- - - // Controls whether a top border is drawn on tabs for editors that have unsaved changes. - "workbench.editor.highlightModifiedTabs": true, - - //-------- Files configuration -------- - - // When enabled, will trim all new lines after the final new line at the end of the file when saving it. - "files.trimFinalNewlines": true, - - // When enabled, insert a new final line at the end of the file when saving it. - "files.insertFinalNewline": true, - - //-------- Live Server configuration -------- - - // Set Custom Port Number of Live Server. Set 0 if you want random port. - "liveServer.settings.port": 5504, - - //-------- Markdown configuration -------- - - // Enable path suggestoins while writing links in markdown files - "markdown.suggest.paths.enabled": true, - - // Defines a default markdown formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter - "[markdown]": { - "editor.defaultFormatter": "DavidAnson.vscode-markdownlint" - }, - - // Enable/disable update table of contents on save - "markdown.extension.toc.updateOnSave": false, - - "[python]": { - "editor.defaultFormatter": "charliermarsh.ruff", - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.fixAll.ruff": "explicit", - "source.organizeImports.ruff": "explicit" - } - } -} From b8f9676877f39f867c0eab61688cd45d3bb118ef Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sun, 12 Jan 2025 21:46:45 +0100 Subject: [PATCH 14/15] Codes to count vowels --- solutions/count_vowels.py | 2 +- solutions/tests/test_count_vowels.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/solutions/count_vowels.py b/solutions/count_vowels.py index 2ab9cfef1..61c19e7da 100644 --- a/solutions/count_vowels.py +++ b/solutions/count_vowels.py @@ -3,7 +3,7 @@ """ A module for counting the number of vowels in a given string. -Created on 01 Jan 2025 +Created on 29 Dec 2024 @author: Daniel Oluwaluyi """ diff --git a/solutions/tests/test_count_vowels.py b/solutions/tests/test_count_vowels.py index 073ffab32..cc99106c2 100644 --- a/solutions/tests/test_count_vowels.py +++ b/solutions/tests/test_count_vowels.py @@ -3,7 +3,7 @@ """ A module for testing the count_vowels function. -Created on 01 Jan 2025 +Created on 29 Dec 2024 @author: Daniel Oluwaluyi """ From f2651b732753af4aafdf5177d3ee835df3de5426 Mon Sep 17 00:00:00 2001 From: Daniel Oluwaluyi Date: Sun, 12 Jan 2025 22:42:16 +0100 Subject: [PATCH 15/15] resolve json setting --- .vscode/settings.json | 126 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..4ab96e711 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,126 @@ +{ + // https://vscode-docs.readthedocs.io/en/stable/customization/userandworkspace/#default-settings + //-------- Editor configuration -------- + + // Controls auto save of editors that have unsaved changes.: https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save + "files.autoSave": "onFocusChange", + + // Format a file on save. A formatter must be available. + "editor.formatOnSave": true, + + // Controls whether the editor should automatically format the pasted content. A formatter must be available. + "editor.formatOnPaste": true, + + // Controls whether the editor should render indent quides + "editor.guides.indentation": true, + + // Controls whether the editor should highlight the active indent guide. + "editor.guides.highlightActiveIndentation": true, + + // Controls the rendering size of tabs in characters. Accepted values: "auto", 2, 4, 6, etc. If set to "auto", the value will be guessed when a file is opened. + "editor.tabSize": 2, + + // Defines a default formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter + "editor.defaultFormatter": "esbenp.prettier-vscode", + + // Controls bracket pair colorization is enabled or not + "editor.bracketPairColorization.enabled": true, + + // Controls whether bracket pair guides are enabled or not. (true, active, false) + "editor.guides.bracketPairs": "active", + + // Controls whether horizontal bracket pair guides are enabled or not. + "editor.guides.bracketPairsHorizontal": "active", + + // Controls whether the editor should highlight the active bracket pair. + "editor.guides.highlightActiveBracketPair": true, + + // Controls whether the editor has linked editing enabled. + "editor.linkedEditing": true, + + //-------- HTML configuration -------- + + // Enable/disable auto closing of HTML tags + "html.autoClosingTags": true, + + // Configures if the built-in HTML language suggests HTML5 tags, properties and values. + "html.suggest.html5": true, + + // Defines a default HTML formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter + "[html]": { + "editor.defaultFormatter": "vscode.html-language-features" + }, + + //-------- Emmet configuration -------- + + // Enables completion when you are writing Emmet appreveation. + "html-css-class-completion.enableEmmetSupport": true, + + //-------- JavaScript configuration -------- + + // Enable/disable auto closing of JSX tags. + "javascript.autoClosingTags": true, + + // Enable/disable auto import suggestions. + "javascript.suggest.autoImports": true, + + // Enable/disable automatic updating of import paths when you rename or move a file in VS Code. + "javascript.updateImportsOnFileMove.enabled": "always", + + // Enable/disable suggestoins for paths in import statement and require calls. (change it to false to be able to use Path Intellisense extension) + "javascript.suggest.paths": false, + + //-------- TypeScript configuration -------- + + // Enable/disable auto closing of JSX tags. + "typescript.autoClosingTags": true, + + // Enable/disable auto import suggestions. + "typescript.suggest.autoImports": true, + + // Enable/disable automatic updating of import paths when you rename or move a file in VS Code. + "typescript.updateImportsOnFileMove.enabled": "always", + + // Enable/disable suggestoins for paths in import statement and require calls. (change it to false to be able to use Path Intellisense extension) + "typescript.suggest.paths": false, + + //-------- Work Bench configuration -------- + + // Controls whether a top border is drawn on tabs for editors that have unsaved changes. + "workbench.editor.highlightModifiedTabs": true, + + //-------- Files configuration -------- + + // When enabled, will trim all new lines after the final new line at the end of the file when saving it. + "files.trimFinalNewlines": true, + + // When enabled, insert a new final line at the end of the file when saving it. + "files.insertFinalNewline": true, + + //-------- Live Server configuration -------- + + // Set Custom Port Number of Live Server. Set 0 if you want random port. + "liveServer.settings.port": 5504, + + //-------- Markdown configuration -------- + + // Enable path suggestoins while writing links in markdown files + "markdown.suggest.paths.enabled": true, + + // Defines a default markdown formatter which takes precedence over all other formatter settings. Must be the identifier of an extension contributing a formatter + "[markdown]": { + "editor.defaultFormatter": "DavidAnson.vscode-markdownlint" + }, + + // Enable/disable update table of contents on save + "markdown.extension.toc.updateOnSave": false, + + "[python]": { + "editor.defaultFormatter": "charliermarsh.ruff", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.fixAll.ruff": "explicit", + "source.organizeImports.ruff": "explicit" + } + } + }