Skip to content

Commit a3371b8

Browse files
author
Reijonen Pekka
committed
added example from article whats __init__ for me
1 parent e7ef287 commit a3371b8

6 files changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ Repository tokens are required for (a) all private repos, (b) public repos not u
7070
### Cobertura Reports
7171
Cobertura reports can expire - Codecov will reject reports that are older than 12 hours. The logs contain details if a report expired.
7272

73+
## Additions according to web article
74+
This is to give beginners a good start for making python packages. Example in following article added as it is, without any changes:
75+
https://towardsdatascience.com/whats-init-for-me-d70a312da583
76+
7377
## Links
7478
- [Community Boards](https://community.codecov.io)
7579
- [Support](https://codecov.io/support)

example_pkg/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .foo import *
2+
from .bar import *
3+
from .baz import *
4+

example_pkg/bar.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def bar_func():
2+
print("this is a bar function")
3+
return "bar"

example_pkg/baz.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def baz_func():
2+
print("this is a baz function")
3+
return "baz"

example_pkg/foo.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def foo_func():
2+
print("this is a foo function")
3+
return "foo"

tests.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
import unittest
22

33
import awesome
4+
import example_pkg
45

56

67
class TestMethods(unittest.TestCase):
78
def test_add(self):
89
self.assertEqual(awesome.smile(), ":)")
10+
11+
def test_anotherOne(self):
12+
foores = example_pkg.foo_func()
13+
barres = example_pkg.bar_func()
14+
bazres = example_pkg.baz_func()
15+
self.assertRegexpMatches(barres,".*bar.*")
916

1017

1118
if __name__ == '__main__':

0 commit comments

Comments
 (0)