Skip to content
Snippets Groups Projects
Commit 6c979d4d authored by Felipe Delestro Matos's avatar Felipe Delestro Matos
Browse files

updated tests

parent 56e4301c
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,9 @@ On the root of the repository, at minimum you should have:
- A single `project_name` directory that contains all the main code
- requirements.txt (for the pip requirements)
Depending on your project, you might also have:
- y
### Code directory
Use a simple but meaningful name, as this is the name you're project is going to be imported in case it is packed as a library.
......@@ -16,6 +19,9 @@ Here we use `qimex` as in **QIM** **Ex**ample
## Coding guidelines
Details of the coding guidelines can be found at the QIM Gitlab Wiki:
https://lab.compute.dtu.dk/groups/QIM/-/wikis/Home/Coding-standards
## Testing
We should use `pytest` to manage unit testing of the repository.
......
def say_hello(user):
"""Prints a greeting message to the specified user.
"""Generates a greeting message for the specified user.
Args:
user (str): The name of the user to greet.
user (str): The name of the user.
Returns:
None
str: The greeting message.
Example:
>>> say_hello('Alice')
Hello Alice!
'Hello Alice!'
"""
print (f'Hello {user}!')
str = (f'Hello {user}!')
return str
\ No newline at end of file
import qimex
from io import StringIO
import sys
def test_say_hello():
# Redirect standard output to a StringIO object
captured_output = StringIO()
sys.stdout = captured_output
# Call the function to test
qimex.examples.say_hello('Alice')
# Restore the standard output
sys.stdout = sys.__stdout__
# Get the captured output
output = captured_output.getvalue().strip()
# Assert that the expected output is printed to the console
assert output == 'Hello Alice!'
user = "Alice"
expected_output = "Hello Alice!"
result = qimex.examples.say_hello(user)
assert result == expected_output
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment