python tests: allow running from separate build dir

The VTY tests assume that $top_builddir == $top_srcdir. Use the script's
location from sys.path[0] to find the correct locations of example configs even
when building in another directory.

Change-Id: I2731f361e3b72d0980968e6cf83594ea450db7c2
This commit is contained in:
Neels Hofmeyr 2017-02-24 17:55:11 +01:00
parent ca06e040cc
commit 476c4bb7d1
3 changed files with 9 additions and 4 deletions

View File

@ -30,7 +30,8 @@ import struct
import osmopy.obscvty as obscvty
import osmopy.osmoutil as osmoutil
confpath = '.'
# to be able to find $top_srcdir/doc/...
confpath = os.path.join(sys.path[0], '..')
verbose = False
class TestCtrlBase(unittest.TestCase):

View File

@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import time
import unittest
import socket
@ -25,7 +26,7 @@ import socket
import osmopy.obscvty as obscvty
import osmopy.osmoutil as osmoutil
confpath = '.'
confpath = os.path.join(sys.path[0], '..')
class TestVTYBase(unittest.TestCase):

View File

@ -24,10 +24,13 @@ import subprocess
import osmopy.obscvty as obscvty
import osmopy.osmoutil as osmoutil
sys.path.append("../contrib")
# add $top_srcdir/contrib to find ipa.py
sys.path.append(os.path.join(sys.path[0], '..', 'contrib'))
from ipa import IPA
confpath = '.'
# to be able to find $top_srcdir/doc/...
confpath = os.path.join(sys.path[0], '..')
class TestVTYBase(unittest.TestCase):