| ... | @@ -40,7 +40,7 @@ For example, your project structure could be like this: |
... | @@ -40,7 +40,7 @@ For example, your project structure could be like this: |
|
|
|
|
|
|
|
```
|
|
```
|
|
|
example-repo/
|
|
example-repo/
|
|
|
├ qimex/
|
|
├ myproject/
|
|
|
│ ├ __init__.py
|
|
│ ├ __init__.py
|
|
|
│ └ examples.py
|
|
│ └ examples.py
|
|
|
├ tests/
|
|
├ tests/
|
| ... | @@ -54,26 +54,21 @@ example-repo/ |
... | @@ -54,26 +54,21 @@ example-repo/ |
|
|
Inside `examples.py` you could have this function:
|
|
Inside `examples.py` you could have this function:
|
|
|
|
|
|
|
|
```python
|
|
```python
|
|
|
|
|
|
|
|
def say_hello(user):
|
|
def say_hello(user):
|
|
|
|
|
|
|
|
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():
|
|
|
expected_output = "Hello Alice!"
|
|
expected_output = "Hello Alice!"
|
|
|
result = qimex.examples.say_hello("Alice")
|
|
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.
|
| ... | |
... | |
| ... | | ... | |