Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Example repository - Level 2 - Stable
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tutorials
Example repository - Level 2 - Stable
Commits
6c979d4d
Commit
6c979d4d
authored
2 years ago
by
Felipe Delestro Matos
Browse files
Options
Downloads
Patches
Plain Diff
updated tests
parent
56e4301c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+6
-0
6 additions, 0 deletions
README.md
qimex/examples.py
+8
-5
8 additions, 5 deletions
qimex/examples.py
tests/test_examples.py
+4
-18
4 additions, 18 deletions
tests/test_examples.py
with
18 additions
and
23 deletions
README.md
+
6
−
0
View file @
6c979d4d
...
@@ -9,6 +9,9 @@ On the root of the repository, at minimum you should have:
...
@@ -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
-
A single
`project_name`
directory that contains all the main code
-
requirements.txt (for the pip requirements)
-
requirements.txt (for the pip requirements)
Depending on your project, you might also have:
-
y
### Code directory
### 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.
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
...
@@ -16,6 +19,9 @@ Here we use `qimex` as in **QIM** **Ex**ample
## Coding guidelines
## 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
## Testing
We should use
`pytest`
to manage unit testing of the repository.
We should use
`pytest`
to manage unit testing of the repository.
...
...
This diff is collapsed.
Click to expand it.
qimex/examples.py
+
8
−
5
View file @
6c979d4d
def
say_hello
(
user
):
def
say_hello
(
user
):
"""
Print
s a greeting message
to
the specified user.
"""
Generate
s a greeting message
for
the specified user.
Args:
Args:
user (str): The name of the user
to greet
.
user (str): The name of the user.
Returns:
Returns:
None
str: The greeting message.
Example:
Example:
>>>
say_hello
(
'
Alice
'
)
>>>
say_hello
(
'
Alice
'
)
Hello
Alice
!
'
Hello Alice!
'
"""
"""
print
(
f
'
Hello
{
user
}
!
'
)
str
=
(
f
'
Hello
{
user
}
!
'
)
return
str
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/test_examples.py
+
4
−
18
View file @
6c979d4d
import
qimex
import
qimex
from
io
import
StringIO
import
sys
def
test_say_hello
():
def
test_say_hello
():
# Redirect standard output to a StringIO object
user
=
"
Alice
"
captured_output
=
StringIO
()
expected_output
=
"
Hello Alice!
"
sys
.
stdout
=
captured_output
result
=
qimex
.
examples
.
say_hello
(
user
)
assert
result
==
expected_output
# Call the function to test
\ No newline at end of file
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!
'
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment