Review at  https://gerrit.osmocom.org/5777

Fix absolute import issue in py3

As of 577f2a95e4f01c58a0a4f4ccb3b70d9c048b626e in osmo-ci, the
contrib/jenkins.sh isused forinstallation. This causes the issue with
python3 because test coded use absolute import by default.

Fix this by adding relative path and import from ../osmopy to make
sure test code uses the current module and not the one which might be
already installed in the system.

Change-Id: I8ac3c0d45fb2e1d18646048703ac405be1c7e539
---
M tests/test_py3.py
1 file changed, 6 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests 
refs/changes/77/5777/1

diff --git a/tests/test_py3.py b/tests/test_py3.py
index 3a96d9f..909d057 100644
--- a/tests/test_py3.py
+++ b/tests/test_py3.py
@@ -2,7 +2,12 @@
 
 # just a smoke test for osmopy
 
-import asyncio, random
+import asyncio, random, sys, os
+
+# we have to use this ugly hack to workaroundbrokenrelative imports in py3:
+# from ..osmopy.osmo_ipa import Ctrl
+# does not work as expected
+sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
 from osmopy.osmo_ipa import Ctrl
 from osmopy import __version__
 

-- 
To view, visit https://gerrit.osmocom.org/5777
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ac3c0d45fb2e1d18646048703ac405be1c7e539
Gerrit-PatchSet: 1
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Max <[email protected]>

Reply via email to