many unit tests issues with objects compared to strings
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Dashboard (Horizon) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Running unit tests of Horizon in Debian Unstable leads to many unit test failures like this one below.
My instinct tells me that this is Python 3.12 related, but I'm not sure. Here's a pip freeze output with the installed build-dependency of the package:
alabaster==0.7.12
appdirs==1.4.4
asgiref==3.7.2
async-timeout=
attrs==23.1.0
autopage==0.4.0
Babel==2.10.3
blinker==1.6.2
calmjs==3.4.2
calmjs.parse==1.2.5
calmjs.types==1.0.1
certifi==2023.7.22
chardet==5.2.0
charset-
cliff==4.2.0
cmd2==2.4.3+ds
coverage==7.2.7
cryptography=
csscompressor=
debtcollector=
decorator==5.1.1
Deprecated==1.2.14
deprecation==2.0.7
Django==4.2.5
django-
django-
django-
django-
dnspython==2.4.2
docutils==0.19
dogpile.
dulwich==0.21.6
enmerkar==0.7.1
eventlet==0.33.1
exceptiongroup=
execnet==2.0.0
extras==1.0.0
fasteners==0.17.3
fixtures==4.0.1
flake8==5.0.4
freezegun==1.2.1
futurist==2.4.1
greenlet==2.0.2
h11==0.14.0
hacking==4.1.0
idna==3.3
imagesize==1.4.1
importlib-
iniconfig==1.1.1
iso8601==1.0.2
jaraco.
jeepney==0.8.0
Jinja2==3.1.2
jmespath==1.0.1
jsonpatch==1.32
jsonpointer==2.3
jsonschema==4.10.3
keyring==24.2.0
keystoneauth1=
lxml==4.9.3
Mako==1.2.4.dev0
MarkupSafe==2.1.3
mccabe==0.7.0
monotonic==1.6
more-itertools=
msgpack==1.0.3
netaddr==0.8.0
netifaces==0.11.0
oauthlib==3.2.2
openstackdocsth
openstacksdk==1.0.1
os-client-
os-service-
osc-lib==2.8.1
oslo.concurrenc
oslo.config==9.1.1
oslo.context==5.1.1
oslo.i18n==6.0.0
oslo.log==5.2.0
oslo.policy==4.1.1
oslo.serializat
oslo.upgradeche
oslo.utils==6.1.0
osprofiler==3.4.3
outcome==1.2.0
packaging==23.1
pbr==5.11.1
pep8==1.7.1
pluggy==1.3.0
ply==3.11
prettytable==3.6.0
pycodestyle==2.10.0
pyflakes==2.5.0
Pygments==2.15.1
pyinotify==0.9.6
PyJWT==2.7.0
pymongo==3.11.0
pyOpenSSL==23.0.0
pyparsing==3.1.1
pyperclip==1.8.2
pyrsistent==0.18.1
pyScss==1.4.0
pytest==7.4.2
pytest-
pytest-xdist==3.3.1
python-
python-
python-
python-
python-
python-
python-
python-
pytz==2023.3.post1
PyYAML==6.0.1
rcssmin==1.1.0
redis==4.3.4
requests==2.31.0
requestsexcepti
rfc3986==1.5.0
rjsmin==1.2.0
roman==3.3
SecretStorage=
selenium==4.13.0
semantic-
simplejson==3.19.1
six==1.16.0
sniffio==1.2.0
snowballstemmer
sortedcontainer
Sphinx==5.3.0
sqlparse==0.4.2
stevedore==5.1.0
testscenarios=
testtools==2.5.0
trio==0.22.2
trio-websocket=
urllib3==1.26.16
warlock==2.0.1
wcwidth==0.2.5
WebOb==1.8.6
wrapt==1.14.1
wsproto==1.2.0
XStatic==1.0.3
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
XStatic-
xvfbwrapper==0.2.9
zipp==1.0.0
and here's a typical failure below. Note that there's maybe more than 3 dozen of issues like it:
__________________ WorkflowsTests.
[gw3] linux -- Python 3.11.5 /usr/bin/python3.11
self = <horizon.
def test_workflow_
req = self.factory.
flow = WorkflowForTest
> self.assertQuer
horizon/
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/
return self.assertQuer
/usr/lib/
return self.assertEqua
E AssertionError: Lists differ: [<StepOne: action_one>, <StepTwo: action_two>] != ['<StepOne: action_one>', '<StepTwo: action_two>']
E
E First differing element 0:
E <StepOne: action_one>
E '<StepOne: action_one>'
E
E - [<StepOne: action_one>, <StepTwo: action_two>]
E + ['<StepOne: action_one>', '<StepTwo: action_two>']
E ? + + + +
Probably, it used to be that Python returned strings, but now it's not? Anyways, calling repr() on each object fixes it, with something like this:
though, this breaks in earlier environment, as a map isn't a list, so this really fixes all cases:
My patch here fixes them all:
https:/
Cheers,
Thomas
Changed in horizon: | |
status: | New → In Progress |
Reviewed: https:/ /review. opendev. org/c/openstack /horizon/ +/897310 /opendev. org/openstack/ horizon/ commit/ 8770753fcc8f4c2 24c35b761d64174 c0081cad00
Committed: https:/
Submitter: "Zuul (22348)"
Branch: master
commit 8770753fcc8f4c2 24c35b761d64174 c0081cad00
Author: Thomas Goirand <email address hidden>
Date: Wed Oct 4 11:44:00 2023 +0200
Specify transform=repr in assertQuerysetE qual()
Previously "repr" was automatically applied to "qs" argument of setEqual( ) and most horizon unittest behaviors assume it.
assertQuery
It was deprecated in Django 3.2 and removed in Django 4.1. We need to
specify transform=repr explicitly to use the existing behavior.
[1] https:/ /docs.djangopro ject.com/ en/3.2/ topics/ testing/ tools/# django. test.Transactio nTestCase. assertQuerysetE qual
Closes-Bug: #2038474 889639e25509c8e 614268c1d26
Change-Id: Ie7c7e9a1efc492