diff --git a/t/Dockerfile b/t/Dockerfile index 8725620..54e3dca 100644 --- a/t/Dockerfile +++ b/t/Dockerfile @@ -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 diff --git a/t/testrunner b/t/testrunner index 38623ab..16777ef 100755 --- a/t/testrunner +++ b/t/testrunner @@ -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 diff --git a/tests/test_dlgcnt.py b/tests/test_dlgcnt.py index 73ed328..4c6b9cd 100755 --- a/tests/test_dlgcnt.py +++ b/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)