Merge ~aciba/simplestreams:migrate_to_pytest into simplestreams:master

Proposed by Alberto Contreras
Status: Merged
Approved by: Paride Legovini
Approved revision: 15f9482fa6b44b21ef9f0a134428b51bc61f4f2f
Merge reported by: Server Team CI bot
Merged at revision: not available
Proposed branch: ~aciba/simplestreams:migrate_to_pytest
Merge into: simplestreams:master
Diff against target: 163 lines (+31/-33)
6 files modified
Makefile (+2/-2)
debian/control (+2/-1)
tests/unittests/test_contentsource.py (+5/-5)
tests/unittests/test_glancemirror.py (+0/-1)
tests/unittests/test_signed_data.py (+16/-16)
tox.ini (+6/-8)
Reviewer Review Type Date Requested Status
Paride Legovini Approve
Thomas Bechtold (community) Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+430635@code.launchpad.net

Commit message

migrate nose to pytest

nose is not supported on python 3.10+

Fixes https://bugs.launchpad.net/simplestreams/+bug/1990495

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomas Bechtold (toabctl) wrote :

thx!

review: Approve
Revision history for this message
Paride Legovini (paride) wrote :

Approving for CI to merge. Thanks!

review: Approve
Revision history for this message
Alberto Contreras (aciba) wrote :

It was a pleasure!

Revision history for this message
Adam Collard (adam-collard) wrote :

./tools/tenv: 21: exec: pytest: not found

autopkgtest is failing

Revision history for this message
Adam Collard (adam-collard) wrote :

I expect this is because python3-pytest package installs /usr/bin/py.test-3 and not anything on $PATH called pytest

Of course `python3 -m pytest` is the other option

Revision history for this message
Paride Legovini (paride) wrote :

Yep saw that, the build recipe failed, thanks. It's not even an autopkgtest failure, it's the build-time dh_auto_test target that fails. I'm preparing a MP to fix it.

Revision history for this message
Paride Legovini (paride) wrote :

Interestingly Kinetic's python3-pytest does install /usr/bin/pytest, which is why I didn't hit the FTBFS locally. More precisely /usr/bin/pytest is installed since python3-pytest 6.2.5-3:

pytest (6.2.5-3) unstable; urgency=medium

  * Team upload.
  * Keep upstream's entry points

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/Makefile b/Makefile
index 3387cc1..a763c45 100644
--- a/Makefile
+++ b/Makefile
@@ -11,9 +11,9 @@ build:
11test: test2 test311test: test2 test3
1212
13test3: examples-sign13test3: examples-sign
14 $(TENV) nosetests3 -v tests/14 $(TENV) pytest -v tests/
15test2: examples-sign15test2: examples-sign
16 $(TENV) nosetests -v tests/16 $(TENV) pytest -v tests/
1717
18flake8:18flake8:
19 # any means run via 'flake8' or 'python3 -m flake8'19 # any means run via 'flake8' or 'python3 -m flake8'
diff --git a/debian/control b/debian/control
index 697def8..51372b8 100644
--- a/debian/control
+++ b/debian/control
@@ -10,7 +10,8 @@ Build-Depends: debhelper-compat (= 13),
10 python3-glanceclient,10 python3-glanceclient,
11 python3-keystoneclient,11 python3-keystoneclient,
12 python3-mock,12 python3-mock,
13 python3-nose,13 python3-pytest,
14 python3-pytest-cov,
14 python3-requests (>= 1.1),15 python3-requests (>= 1.1),
15 python3-setuptools,16 python3-setuptools,
16 python3-swiftclient,17 python3-swiftclient,
diff --git a/tests/unittests/test_contentsource.py b/tests/unittests/test_contentsource.py
index 862a147..ef838a2 100644
--- a/tests/unittests/test_contentsource.py
+++ b/tests/unittests/test_contentsource.py
@@ -8,7 +8,7 @@ from simplestreams import objectstores
8from simplestreams import contentsource8from simplestreams import contentsource
9from subprocess import Popen, PIPE, STDOUT9from subprocess import Popen, PIPE, STDOUT
10from unittest import TestCase, skipIf10from unittest import TestCase, skipIf
11from nose.tools import raises11import pytest
1212
1313
14class RandomPortServer(object):14class RandomPortServer(object):
@@ -253,11 +253,11 @@ class TestResume(BaseDirUsingTestCase):
253 # header, so we get two 'hello's.253 # header, so we get two 'hello's.
254 assert contents == b'hellohello world\n', contents254 assert contents == b'hellohello world\n', contents
255255
256 @raises(Exception)
257 def test_post_open_set_start_pos(self):256 def test_post_open_set_start_pos(self):
258 cs = contentsource.UrlContentSource(self.furl_for('foo'))257 with pytest.raises(Exception):
259 cs.open()258 cs = contentsource.UrlContentSource(self.furl_for('foo'))
260 cs.set_start_pos(1)259 cs.open()
260 cs.set_start_pos(1)
261261
262 def test_percent_callback(self):262 def test_percent_callback(self):
263 data = {'dld': 0}263 data = {'dld': 0}
diff --git a/tests/unittests/test_glancemirror.py b/tests/unittests/test_glancemirror.py
index cf4195b..53b624c 100644
--- a/tests/unittests/test_glancemirror.py
+++ b/tests/unittests/test_glancemirror.py
@@ -161,7 +161,6 @@ class FakeImages(object):
161 self.image_import_calls.append(image_id)161 self.image_import_calls.append(image_id)
162162
163 def list(self, **kwargs):163 def list(self, **kwargs):
164 # from nose.tools import set_trace; set_trace()
165 return list(self.imgdb.values())164 return list(self.imgdb.values())
166165
167166
diff --git a/tests/unittests/test_signed_data.py b/tests/unittests/test_signed_data.py
index 02f2dff..2b31e76 100644
--- a/tests/unittests/test_signed_data.py
+++ b/tests/unittests/test_signed_data.py
@@ -2,7 +2,7 @@ import shutil
2import subprocess2import subprocess
3import tempfile3import tempfile
44
5from nose.tools import raises5import pytest
6from os.path import join6from os.path import join
7from simplestreams import mirrors7from simplestreams import mirrors
8from simplestreams import objectstores8from simplestreams import objectstores
@@ -15,27 +15,27 @@ def _tmp_reader():
15 return mirrors.ObjectStoreMirrorReader(sstore)15 return mirrors.ObjectStoreMirrorReader(sstore)
1616
1717
18@raises(subprocess.CalledProcessError)
19def test_read_bad_data():18def test_read_bad_data():
20 good = join(EXAMPLES_DIR, "foocloud", "streams", "v1", "index.sjson")19 with pytest.raises(subprocess.CalledProcessError):
21 bad = join(tempfile.gettempdir(), "index.sjson")20 good = join(EXAMPLES_DIR, "foocloud", "streams", "v1", "index.sjson")
22 shutil.copy(good, bad)21 bad = join(tempfile.gettempdir(), "index.sjson")
23 with open(bad, 'r+') as f:22 shutil.copy(good, bad)
24 lines = f.readlines()23 with open(bad, 'r+') as f:
25 f.truncate()24 lines = f.readlines()
26 f.seek(0)25 f.truncate()
27 for line in lines:26 f.seek(0)
28 f.write(line.replace('foovendor', 'attacker'))27 for line in lines:
28 f.write(line.replace('foovendor', 'attacker'))
2929
30 _tmp_reader().read_json("index.sjson")30 _tmp_reader().read_json("index.sjson")
3131
3232
33@raises(SignatureMissingException)
34def test_read_unsigned():33def test_read_unsigned():
35 # empty files aren't signed34 with pytest.raises(SignatureMissingException):
36 open(join(tempfile.gettempdir(), 'index.json'), 'w').close()35 # empty files aren't signed
36 open(join(tempfile.gettempdir(), 'index.json'), 'w').close()
3737
38 _tmp_reader().read_json("index.json")38 _tmp_reader().read_json("index.json")
3939
4040
41def test_read_signed():41def test_read_signed():
diff --git a/tox.ini b/tox.ini
index b450afc..4d09a1b 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,15 +8,13 @@ setenv =
8commands = 8commands =
9 {toxinidir}/tools/create-gpgdir9 {toxinidir}/tools/create-gpgdir
10 {toxinidir}/tools/sign-examples10 {toxinidir}/tools/sign-examples
11 {envpython} -m nose {posargs:--with-coverage --cover-erase \11 {envpython} -m pytest {posargs:--cov=simplestreams --cov-branch tests}
12 --cover-branches --cover-package=simplestreams --cover-inclusive \
13 tests}
14deps =12deps =
15 coverage
16 mock13 mock
17 nose
18 python-glanceclient14 python-glanceclient
19 python-keystoneclient 15 python-keystoneclient
16 pytest
17 pytest-cov
2018
21[testenv:flake8]19[testenv:flake8]
22basepython = python320basepython = python3
@@ -27,9 +25,9 @@ commands = {toxinidir}/tools/run-flake8 {posargs}
2725
28[testenv:py3-noopenstack]26[testenv:py3-noopenstack]
29deps =27deps =
30 coverage
31 mock28 mock
32 nose29 pytest
30 pytest-cov
33basepython = python331basepython = python3
3432
35[testenv:snap]33[testenv:snap]

Subscribers

People subscribed via source and target branches