Skip to content

Commit db0bc16

Browse files
committed
Add import of parent dir
1 parent 97a32d6 commit db0bc16

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ PYTHONPATH=. nose2
88
if you haven't installed this package in your pythonpath anywhere (through virtualenv or side wide).
99

1010
Note now I modify the PYTHONPATH environment variable to tell nose2 where to find the package. I also use relative imports inside my package to make sure all modules can be found.
11+
12+
In subpackage/utils.py I actually import from the parent directory with the absolute import

my_package/subpackage/__init__.py

Whitespace-only changes.

my_package/subpackage/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from my_package import MyApp
2+
3+
def somefunction(operation, number1, number2):
4+
app=MyApp()
5+
return app.do(operation, number1, number2)

tests/test_subpackage.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from unittest import TestCase
2+
from my_package.subpackage.utils import somefunction
3+
4+
class TestUtils(TestCase):
5+
def test_somefunction(self):
6+
self.assertEqual(somefunction('add', 5, 6), 11)
7+

0 commit comments

Comments
 (0)