Changes
Page history
Update Coding standards
authored
Jun 15, 2023
by
fima
Show whitespace changes
Inline
Side-by-side
Home/Coding-standards.md
View page @
0abefef4
...
@@ -53,26 +53,26 @@ example-repo/
...
@@ -53,26 +53,26 @@ example-repo/
Inside
`examples.py`
you could have this function:
Inside
`examples.py`
you could have this function:
```
python
```
python
def
say_hello
(
user
):
if
not
isinstance
(
user
,
str
):
def
say_hello
(
user
):
raise
TypeError
(
"
The
'
user
'
argument must be a string.
"
)
greeting
=
(
f
'
Hello
{
user
}
!
'
)
greeting
=
(
f
'
Hello
{
user
}
!
'
)
return
greeting
return
greeting
```
```
This function simply receives a string and returns another string greeting the user.
This function simply receives a string and returns another string greeting the user.
A
`test_examples.py`
should contain the test for it:
A
`test_examples.py`
should contain the test for it:
```
python
```
python
def
test_say_hello
():
def
test_say_hello
():
"""
Checks default behaviour
"""
user
=
"
Alice
"
expected_output
=
"
Hello Alice!
"
expected_output
=
"
Hello Alice!
"
result
=
qimex
.
examples
.
say_hello
(
user
)
result
=
qimex
.
examples
.
say_hello
(
"
Alice
"
)
assert
result
==
expected_output
assert
result
==
expected_output
```
```
This is simply running the function and checking if the result is as expected.
This is simply running the function and checking if the result is as expected.
...
...
...
...