#66 pytest failure if run on an openqa server already configured with non-default in config file
Opened 4 years ago by michelmno. Modified 4 years ago

pytest failure if run on an openqa server already configured with non-default in config file

I am not familiar with pytest, so I basically called it on my PowerPC machine with not specific arguments, and it is reporting errors similar to exemples below (2)

Is there specific syntax/arguments to pass to handle the local hostname by pytest ?

(2) my PowerPC host is "abanc.test.toulouse-stg.fr.ibm.com"
and failures report it as a problem (with or without http prefix)

>               assert fake_schedule.call_args[1]['openqa_hostname'] == oqah
E               AssertionError: assert 'http://abanc...tg.fr.ibm.com' == 'openqa.fedoraproject.org'
E                 - http://abanc.test.toulouse-stg.fr.ibm.com
E                 + openqa.fedoraproject.org
tests/test_consumers.py:317: AssertionError
===
>               assert fake_schedule.call_args[1]['openqa_hostname'] == oqah
E               AssertionError: assert 'abanc.test.t...tg.fr.ibm.com' == 'openqa.stg.fedoraproject.org'
E                 - abanc.test.toulouse-stg.fr.ibm.com
E                 + openqa.stg.fedoraproject.org
tests/test_consumers.py:317: AssertionError

comment already sent by @adamwill via email:

Ah, hm; I think basically the tests aren't 'safe' if you run them in
such a way that a config file which sets certain values will be read.
The tests assume those values will be their defaults in the absence of
a config file.

Can you file an issue on this? I'll think about the best way to fix it.

Hello @adamwill, I do not know how to solve this issue,

My understanding is that we should mock the openqa_hostname and openqa_baseurl methods, but they have property decorator, so my trial code to mock openqa_hostname in test/test_consumer.py (1) is failing misarably (2)
I do not know how to manage that between the class and the instance.

Do you have a suggestion for correction ?

$pytest -v -x --full-trace tests/test_consumers.py
...
E           AttributeError: <module 'fedora_openqa.consumer' from '/usr/lib/python2.7/site-packages/fedora_openqa-3.0.0-py2.7.egg/fedora_openqa/consumer.pyc'> does not have the attribute u'openqa_hostname'

/usr/lib/python2.7/site-packages/mock/mock.py:1343: AttributeError

Sorry, I've had more urgent stuff to work on recently. The short term workaround is just 'run the tests in such a way that the config file doesn't kick in' - move it out of the way temporarily, or run them as another user. For a real fix, my first instinct is to tweak things a bit so the tests don't use the 'real' config files but instead use ones shipped with the source. I just need to get around to it.

Metadata Update from @adamwill:
- Issue priority set to: High
- Issue tagged with: bug

4 years ago

Not much use, but just to note, I just spent like two hours thinking about how to fix this and it's actually kinda hard to come up with anything very clean. Will keep working on it...

Login to comment on this ticket.

Metadata