Skip to content
Snippets Groups Projects
Commit 59a47620 authored by John Feiner's avatar John Feiner
Browse files

Added test, format and lint

parent 66799d66
Branches
No related tags found
Loading
#!/usr/bin/env Python3
#!/usr/bin/env python3
# Automated Testing with Unit Tests
......@@ -7,12 +7,14 @@
# just RETURN a result
def pretty_format(msg, indent=3):
return f"{' '*indent}{msg}"
return f"{' ' * indent}{msg}"
# printing to console would be much more difficult to test
def pretty_output(msg, indent=3):
res = pretty_format(msg,indent)
res = pretty_format(msg, indent)
print(res)
if __name__ == "__main__":
pretty_output("This is visible only if the script is run directly.")
\ No newline at end of file
pretty_output("This is visible only if the script is run directly.")
#!/bin/bash
# startup a code formatting tool
# e.g. ruff
ruff format solution.py
#!/bin/bash
# startup a linter for Python
# e.g.: ruff
ruff check solution.py
echo " Hint: Learn about all the rules with 'ruff rule --all'... "
\ No newline at end of file
import unittest
from tools.solution import pretty_format
from solution import pretty_format
class TestPrettyPrintFunctions(unittest.TestCase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment