Fix running tests on Python 3.7

This commit is contained in:
Mikolaj Izdebski 2018-06-20 12:23:17 +02:00
parent 7078bef0d2
commit e144c6b9ca
2 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,89 @@
From 000eaa96943b0f4634a10a7232355ce59c9efccb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Wed, 20 Jun 2018 11:35:03 +0200
Subject: [PATCH] Rename the async kwarg in call_script to wait (reverses the
logic)
async is a reserved keyword in Python 3.7 and keeping it results
in syntax error. I didn't want to rename the argument to asynch or
async_ without thinking, so I've checked what it does and went with
wait. I reversed the logic because I didn't want it to be nowait.
---
test/pm_request_test.py | 10 +++++-----
test/test_common.py | 4 ++--
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/test/pm_request_test.py b/test/pm_request_test.py
index 92ccbaa..256ab56 100644
--- a/test/pm_request_test.py
+++ b/test/pm_request_test.py
@@ -19,7 +19,7 @@ class PmRequestTest(unittest.TestCase):
def test_ok(self):
(out, err, proc) = call_script(self.scriptpath,
['maven', 'junit:junit'],
- extra_env=self.env, async=True)
+ extra_env=self.env, wait=False)
conn, _ = self.sock.accept()
request = conn.makefile().readline().rstrip()
self.assertEqual(request, "install 'mvn(junit:junit)'")
@@ -31,7 +31,7 @@ class PmRequestTest(unittest.TestCase):
def test_nok(self):
(out, err, proc) = call_script(self.scriptpath,
['maven', 'junit:junit'],
- extra_env=self.env, async=True)
+ extra_env=self.env, wait=False)
conn, _ = self.sock.accept()
request = conn.makefile().readline().rstrip()
self.assertEqual(request, "install 'mvn(junit:junit)'")
@@ -43,7 +43,7 @@ class PmRequestTest(unittest.TestCase):
def test_jar(self):
(out, err, proc) = call_script(self.scriptpath,
['maven', 'gid:aid:jar::'],
- extra_env=self.env, async=True)
+ extra_env=self.env, wait=False)
conn, _ = self.sock.accept()
request = conn.makefile().readline().rstrip()
self.assertEqual(request, "install 'mvn(gid:aid)'")
@@ -55,7 +55,7 @@ class PmRequestTest(unittest.TestCase):
def test_full_coords(self):
(out, err, proc) = call_script(self.scriptpath,
['maven', 'gid:aid:ext:cla:ver'],
- extra_env=self.env, async=True)
+ extra_env=self.env, wait=False)
conn, _ = self.sock.accept()
request = conn.makefile().readline().rstrip()
self.assertEqual(request, "install 'mvn(gid:aid:ext:cla:ver)'")
@@ -67,7 +67,7 @@ class PmRequestTest(unittest.TestCase):
def test_connection_error(self):
(out, err, proc) = call_script(self.scriptpath,
['maven', 'junit:junit'],
- extra_env=self.env, async=True)
+ extra_env=self.env, wait=False)
conn, _ = self.sock.accept()
conn.close()
ret = proc.wait()
diff --git a/test/test_common.py b/test/test_common.py
index 4000b6c..9bdc467 100644
--- a/test/test_common.py
+++ b/test/test_common.py
@@ -24,7 +24,7 @@ for var in ('PYTHONPATH', 'COVERAGE_PROCESS_START'):
SCRIPT_ENV[var] = os.environ[var]
-def call_script(name, args, stdin=None, extra_env={}, async=False):
+def call_script(name, args, stdin=None, extra_env={}, wait=True):
with open("tmpout", 'w') as outfile:
with open("tmperr", 'w') as errfile:
procargs = [sys.executable, name]
@@ -36,7 +36,7 @@ def call_script(name, args, stdin=None, extra_env={}, async=False):
env=env,
stdin=subprocess.PIPE,
universal_newlines=True)
- if async:
+ if not wait:
return (outfile, errfile, proc)
proc.communicate(stdin)
ret = proc.wait()
--
2.14.3

View File

@ -29,6 +29,8 @@ License: BSD
URL: https://github.com/fedora-java/javapackages
Source0: https://github.com/fedora-java/javapackages/archive/%{version}.tar.gz
Patch0: 0001-Rename-the-async-kwarg-in-call_script-to-wait-revers.patch
BuildArch: noarch
BuildRequires: coreutils
@ -149,6 +151,7 @@ This package provides non-essential macros and scripts to support Java packaging
%prep
%setup -q -n javapackages-%{version}
%patch0 -p1
%if %{without asciidoc}
sed -i '/^manpage /d' build
@ -200,6 +203,9 @@ rm -rf %{buildroot}%{_mandir}/man7/gradle_build.7
%license LICENSE
%changelog
* Wed Jun 20 2018 Mikolaj Izdebski <mizdebsk@redhat.com> - 5.2.0-2
- Fix running tests on Python 3.7
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 5.2.0-2
- Rebuilt for Python 3.7