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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QIM
Tutorials
Example repository - Level 2 - Stable
Commits
c7e4f34a
Commit
c7e4f34a
authored
2 years ago
by
Felipe Delestro Matos
Browse files
Options
Downloads
Patches
Plain Diff
CI/CD
parent
9f3b2127
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#17514
passed
2 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+4
-4
4 additions, 4 deletions
README.md
qimex/examples.py
+5
-2
5 additions, 2 deletions
qimex/examples.py
tests/test_examples.py
+8
-2
8 additions, 2 deletions
tests/test_examples.py
with
17 additions
and
8 deletions
README.md
+
4
−
4
View file @
c7e4f34a
...
...
@@ -5,12 +5,12 @@ This is an example repository of how Python projects should be organized as at Q
On the root of the repository, at minimum you should have:
-
README.md
-
LICENSE
-
An
`.gitignore`
file (you can use the one from here as a base template)
-
`.gitignore`
file (you can use the one from here as a base template)
-
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
-
`.gitlab-ci.yml`
for the CI/CD pipeline
### 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.
...
...
@@ -25,8 +25,8 @@ Details of the coding guidelines can be found at the [QIM Gitlab Wiki](https://l
In summary:
-
Use Google style for docstrings.
-
Do not add files larger than 32MB, unless stricly
necessary.
-
Raise errors when
necessary.
-
Avoid large files.
## Testing
...
...
This diff is collapsed.
Click to expand it.
qimex/examples.py
+
5
−
2
View file @
c7e4f34a
...
...
@@ -11,7 +11,10 @@ def say_hello(user):
>>>
say_hello
(
'
Alice
'
)
'
Hello Alice!
'
"""
if
not
isinstance
(
user
,
str
):
raise
TypeError
(
"
The
'
user
'
argument must be a string.
"
)
greeting
=
(
f
'
Hello
{
user
}
!
'
)
str
=
(
f
'
Hello
{
user
}
!
'
)
return
greeting
return
str
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/test_examples.py
+
8
−
2
View file @
c7e4f34a
import
qimex
import
pytest
def
test_say_hello
():
user
=
"
Alice
"
expected_output
=
"
Hello Alice!
"
result
=
qimex
.
examples
.
say_hello
(
user
)
assert
result
==
expected_output
\ No newline at end of file
assert
result
==
expected_output
def
test_say_hello_with_non_string
():
"""
Tests if the correct error is raised
"""
user
=
123
# Non-string argument
with
pytest
.
raises
(
TypeError
):
qimex
.
examples
.
say_hello
(
user
)
\ No newline at end of file
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