TT#68009 Switch from python2 to python3

We also need to switch from python-xmlrunner to python3-pytest, as
the former is not present in Debian unstable/testing anymore (see
<https://bugs.debian.org/935688>), and does not provide python3
support in Debian buster anyway.

Change-Id: I8af9ead2755af2e24f5bedf53d8cd20c4ed63b85
changes/65/33865/3
Guillem Jover 6 years ago
parent e5e8291ce8
commit 50b2460aa6

@ -5,14 +5,16 @@ FROM docker.mgm.sipwise.com/sipwise-buster:latest
# is updated with the current date. It will force refresh of all
# of the base images and things like `apt-get update` won't be using
# old cached versions when the Dockerfile is built.
ENV REFRESHED_AT 2019-06-27
ENV REFRESHED_AT 2019-10-01
# files that get-code generates
COPY t/sources.list.d/builddeps.list /etc/apt/sources.list.d/
COPY t/sources.list.d/preferences /etc/apt/preferences.d/
RUN apt-get update && apt-get install --assume-yes \
lua5.1 lua-unit lua-cjson lua-curl lua-lemock lua-logging lua-argparse lua-check python-xmlrunner
lua5.1 lua-unit lua-cjson lua-curl lua-lemock lua-logging \
lua-argparse lua-check \
python3-pytest
RUN echo './t/testrunner' >>/root/.bash_history

@ -18,4 +18,4 @@ else
fi
RESULTS=${RESULTS} FORMAT=JUNIT ./run_tests.sh
WORKSPACE=${RESULTS}/tmp ./tests/test_dlgcnt.py > ${RESULTS}/reports/test_dlgcnt.xml
WORKSPACE=${RESULTS}/tmp py.test-3 --junit-xml=${RESULTS}/reports/test_dlgcnt.xml ./tests/test_dlgcnt.py

@ -1,9 +1,8 @@
#!/usr/bin/env python
from __future__ import print_function
#!/usr/bin/env python3
import subprocess
import sys
import unittest
import xmlrunner
import os
import io
import shutil
@ -17,7 +16,8 @@ FAKE_PATH = "%s:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin" % FAKE_BIN
def executeAndReturnOutput(command):
p = subprocess.Popen(command, stdout=subprocess.PIPE,
p = subprocess.Popen(command, encoding="utf-8",
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdoutdata, stderrdata = p.communicate()
# print(stdoutdata, file=sys.stdout)
@ -32,7 +32,7 @@ def create_prog(filename, command):
:param unicode command: command to write to test program
"""
with io.open(filename, 'w', encoding='utf-8') as fp:
fp.write(u"#!/bin/bash\n%s\n" % (command, ))
fp.write("#!/bin/bash\n%s\n" % (command, ))
os.fchmod(fp.fileno(), 0o755)
@ -100,14 +100,14 @@ class TestDlgCnt(unittest.TestCase):
self.command = ["./scripts/ngcp-dlgcnt-check", "-k"]
res = executeAndReturnOutput(self.command)
self.assertEqual(res[0], 1, res[2])
self.assertRegexpMatches(res[2], 'illegal option')
self.assertRegex(res[2], 'illegal option')
self.checkNotCmd()
def test_help(self):
self.command = ["./scripts/ngcp-dlgcnt-check", "-h"]
res = executeAndReturnOutput(self.command)
self.assertEqual(res[0], 0, res[2])
self.assertRegexpMatches(res[1], '\toptions\n')
self.assertRegex(res[1], '\toptions\n')
self.checkNotCmd()
def test_inactive(self):
@ -207,7 +207,6 @@ class TestDlgCnt(unittest.TestCase):
if __name__ == '__main__':
unittest.main(
testRunner=xmlrunner.XMLTestRunner(output=sys.stdout),
# these make sure that some options that are not applicable
# remain hidden from the help menu.
failfast=False, buffer=False, catchbreak=False)

Loading…
Cancel
Save