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
1diff --git a/Makefile b/Makefile
2index 3387cc1..a763c45 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -11,9 +11,9 @@ build:
6 test: test2 test3
7
8 test3: examples-sign
9- $(TENV) nosetests3 -v tests/
10+ $(TENV) pytest -v tests/
11 test2: examples-sign
12- $(TENV) nosetests -v tests/
13+ $(TENV) pytest -v tests/
14
15 flake8:
16 # any means run via 'flake8' or 'python3 -m flake8'
17diff --git a/debian/control b/debian/control
18index 697def8..51372b8 100644
19--- a/debian/control
20+++ b/debian/control
21@@ -10,7 +10,8 @@ Build-Depends: debhelper-compat (= 13),
22 python3-glanceclient,
23 python3-keystoneclient,
24 python3-mock,
25- python3-nose,
26+ python3-pytest,
27+ python3-pytest-cov,
28 python3-requests (>= 1.1),
29 python3-setuptools,
30 python3-swiftclient,
31diff --git a/tests/unittests/test_contentsource.py b/tests/unittests/test_contentsource.py
32index 862a147..ef838a2 100644
33--- a/tests/unittests/test_contentsource.py
34+++ b/tests/unittests/test_contentsource.py
35@@ -8,7 +8,7 @@ from simplestreams import objectstores
36 from simplestreams import contentsource
37 from subprocess import Popen, PIPE, STDOUT
38 from unittest import TestCase, skipIf
39-from nose.tools import raises
40+import pytest
41
42
43 class RandomPortServer(object):
44@@ -253,11 +253,11 @@ class TestResume(BaseDirUsingTestCase):
45 # header, so we get two 'hello's.
46 assert contents == b'hellohello world\n', contents
47
48- @raises(Exception)
49 def test_post_open_set_start_pos(self):
50- cs = contentsource.UrlContentSource(self.furl_for('foo'))
51- cs.open()
52- cs.set_start_pos(1)
53+ with pytest.raises(Exception):
54+ cs = contentsource.UrlContentSource(self.furl_for('foo'))
55+ cs.open()
56+ cs.set_start_pos(1)
57
58 def test_percent_callback(self):
59 data = {'dld': 0}
60diff --git a/tests/unittests/test_glancemirror.py b/tests/unittests/test_glancemirror.py
61index cf4195b..53b624c 100644
62--- a/tests/unittests/test_glancemirror.py
63+++ b/tests/unittests/test_glancemirror.py
64@@ -161,7 +161,6 @@ class FakeImages(object):
65 self.image_import_calls.append(image_id)
66
67 def list(self, **kwargs):
68- # from nose.tools import set_trace; set_trace()
69 return list(self.imgdb.values())
70
71
72diff --git a/tests/unittests/test_signed_data.py b/tests/unittests/test_signed_data.py
73index 02f2dff..2b31e76 100644
74--- a/tests/unittests/test_signed_data.py
75+++ b/tests/unittests/test_signed_data.py
76@@ -2,7 +2,7 @@ import shutil
77 import subprocess
78 import tempfile
79
80-from nose.tools import raises
81+import pytest
82 from os.path import join
83 from simplestreams import mirrors
84 from simplestreams import objectstores
85@@ -15,27 +15,27 @@ def _tmp_reader():
86 return mirrors.ObjectStoreMirrorReader(sstore)
87
88
89-@raises(subprocess.CalledProcessError)
90 def test_read_bad_data():
91- good = join(EXAMPLES_DIR, "foocloud", "streams", "v1", "index.sjson")
92- bad = join(tempfile.gettempdir(), "index.sjson")
93- shutil.copy(good, bad)
94- with open(bad, 'r+') as f:
95- lines = f.readlines()
96- f.truncate()
97- f.seek(0)
98- for line in lines:
99- f.write(line.replace('foovendor', 'attacker'))
100+ with pytest.raises(subprocess.CalledProcessError):
101+ good = join(EXAMPLES_DIR, "foocloud", "streams", "v1", "index.sjson")
102+ bad = join(tempfile.gettempdir(), "index.sjson")
103+ shutil.copy(good, bad)
104+ with open(bad, 'r+') as f:
105+ lines = f.readlines()
106+ f.truncate()
107+ f.seek(0)
108+ for line in lines:
109+ f.write(line.replace('foovendor', 'attacker'))
110
111- _tmp_reader().read_json("index.sjson")
112+ _tmp_reader().read_json("index.sjson")
113
114
115-@raises(SignatureMissingException)
116 def test_read_unsigned():
117- # empty files aren't signed
118- open(join(tempfile.gettempdir(), 'index.json'), 'w').close()
119+ with pytest.raises(SignatureMissingException):
120+ # empty files aren't signed
121+ open(join(tempfile.gettempdir(), 'index.json'), 'w').close()
122
123- _tmp_reader().read_json("index.json")
124+ _tmp_reader().read_json("index.json")
125
126
127 def test_read_signed():
128diff --git a/tox.ini b/tox.ini
129index b450afc..4d09a1b 100644
130--- a/tox.ini
131+++ b/tox.ini
132@@ -8,15 +8,13 @@ setenv =
133 commands =
134 {toxinidir}/tools/create-gpgdir
135 {toxinidir}/tools/sign-examples
136- {envpython} -m nose {posargs:--with-coverage --cover-erase \
137- --cover-branches --cover-package=simplestreams --cover-inclusive \
138- tests}
139+ {envpython} -m pytest {posargs:--cov=simplestreams --cov-branch tests}
140 deps =
141- coverage
142 mock
143- nose
144 python-glanceclient
145- python-keystoneclient
146+ python-keystoneclient
147+ pytest
148+ pytest-cov
149
150 [testenv:flake8]
151 basepython = python3
152@@ -27,9 +25,9 @@ commands = {toxinidir}/tools/run-flake8 {posargs}
153
154 [testenv:py3-noopenstack]
155 deps =
156- coverage
157 mock
158- nose
159+ pytest
160+ pytest-cov
161 basepython = python3
162
163 [testenv:snap]

Subscribers

People subscribed via source and target branches