Skip to content

Commit

Permalink
Fixing formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
abdoalsir committed Jan 12, 2025
1 parent d88ae1e commit 5aa9a00
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions solutions/tests/test_chicken_nugget_fun.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import unittest
from io import StringIO
import sys
from pathlib import Path

sys.path.append(str(Path(__file__).parent.parent))
Expand All @@ -9,37 +9,41 @@


class TestChickenNuggetFun(unittest.TestCase):
"""Test cases for the `chicken_nugget_fun` function."""

def test_output(self):
"""Test if the output contains a valid chicken nugget fact."""
# Backup original stdout
original_stdout = sys.stdout
sys.stdout = StringIO()

# Run the function
chicken_nugget_fun()

# Get the output
output = sys.stdout.getvalue()

# Check if the output contains a nugget fact
self.assertTrue(
any(
fact in output
for fact in [
"Chicken nuggets were invented",
"The world record for eating chicken nuggets",
"McDonald's nuggets come in four shapes",
"Try making homemade nuggets",
"Some people dip chicken nuggets in honey",
"Chicken nuggets are eaten by millions",
"Sweet chili sauce makes chicken nuggets extra tasty",
"You can even make plant-based chicken nuggets",
]
try:
# Run the function
chicken_nugget_fun()

# Get the output
output = sys.stdout.getvalue()

# Check if the output contains a nugget fact
self.assertTrue(
any(
fact in output
for fact in [
"Chicken nuggets were invented",
"The world record for eating chicken nuggets",
"McDonald's nuggets come in four shapes",
"Try making homemade nuggets",
"Some people dip chicken nuggets in honey",
"Chicken nuggets are eaten by millions",
"Sweet chili sauce makes chicken nuggets extra tasty",
"You can even make plant-based chicken nuggets",
]
),
"Output did not contain a valid chicken nugget fact.",
)
)

# Restore original stdout
sys.stdout = original_stdout
finally:
# Restore original stdout
sys.stdout = original_stdout


if __name__ == "__main__":
Expand Down

0 comments on commit 5aa9a00

Please sign in to comment.