[PATCH] python/osmo-python-tests[master]: Fix absolute import issue in py3

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Sun Jan 14 17:33:36 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/5777

to look at the new patch set (#2).

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 osmopy/__init__.py
M tests/test_py3.py
2 files changed, 7 insertions(+), 2 deletions(-)


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

diff --git a/osmopy/__init__.py b/osmopy/__init__.py
index d3d3005..c3d4b8c 100644
--- a/osmopy/__init__.py
+++ b/osmopy/__init__.py
@@ -1,4 +1,4 @@
 #!/usr/bin/env python
-__version__ = '0.0.7'
+__version__ = '0.0.8'
 
 __all__ = ['obscvty', 'osmoutil', 'osmo_ipa', 'osmo_interact']
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: newpatchset
Gerrit-Change-Id: I8ac3c0d45fb2e1d18646048703ac405be1c7e539
Gerrit-PatchSet: 2
Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list