Closed kloczek closed 2 years ago
Tomasz Kłoczko wrote at 2021-9-7 20:27 -0700:
I'm trying to package your module as an rpm package. So I'm using the typical build, install and test cycle used on building packages from non-root account.
- "setup.py build"
- "setup.py install --root </install/prefix>"
- "pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
Most zopefoundation
packages have tests designed to be run
by zope.testrunner
(not pytest
).
...
self.assertEqual(lines[-1], ' Module '
'zope.exceptions.tests.test_exceptionformatter, ' 'line %d, in test_extractStack_wo_frame\n' ' lines = fmt.extractStack()\n' % (lineno + 1)) E AssertionError: ' Module test_exceptionformatter, line 364, in tes[53 chars]()\n' != ' Module zope.exceptions.tests.test_exceptionforma[75 chars]()\n' E - Module test_exceptionformatter, line 364, in test_extractStack_wo_frame
This looks as if pytest
starts tests in a different
package environment: with pytest
, the test module seems to
be isolated, with zope.testrunner
embedded in its package hierarchy.
Install zope.testrunner
and try to run the tests with
zope-testrunner --test-path src
instead of pytest
.
Most
zopefoundation
packages have tests designed to be run byzope.testrunner
(notpytest
). ... > self.assertEqual(lines[-1], ' Module ' 'zope.exceptions.tests.test_exceptionformatter, ' 'line %d, in test_extractStack_wo_frame\n' ' lines = fmt.extractStack()\n' % (lineno + 1)) E AssertionError: ' Module test_exceptionformatter, line 364, in tes[53 chars]()\n' != ' Module zope.exceptions.tests.test_exceptionforma[75 chars]()\n' E - Module test_exceptionformatter, line 364, in test_extractStack_wo_frame This looks as ifpytest
starts tests in a different package environment: withpytest
, the test module seems to be isolated, withzope.testrunner
embedded in its package hierarchy. Installzope.testrunner
and try to run the tests withzope-testrunner --test-path src
instead ofpytest
.
Thx will try that bnevertheless it would be way better if pytest would be fully supported because it has a lot of plugins which can extend testing procedure without cahgeing anything in test suite or tested code.
Tomasz Kłoczko wrote at 2021-9-8 03:41 -0700:
... Thx will try that bnevertheless it would be way better if pytest would be fully supported because it has a lot of plugins which can extend testing procedure without cahgeing anything in test suite or tested code.
zope.testrunner
has many built in features - which you
select via parameters.
-- Dieter
zope.testrunner
has many built in features - which you select via parameters. … -- Dieter
Yes, however pytest is waaay more advanced and list of plugins is veeery long :) https://docs.pytest.org/en/latest/reference/plugin_list.html
@kloczek The zopefoundation projects have settled on zope.testrunner
because it was there before pytest
. Projects requiring to be tested using zope.testrunner
cannot be tested using pytest
because pytest
lacks support for at least the feature of layers
. It makes no sense to port the tests to pytest
, please accept this.
Closing this issue as "won't fix".
Thing are changeing and now pytestst
is available and is far more advanced than what has been developed long time ago.
@kloczek I know pytest
and use it in many projects, especially new ones. There is no need to sell pytest
to me.
Additionally I personally did the conversion from zope.testrunner
to pytest
for a personal project, it took way more time than expected. So I know both test runners well enough to make an informed decision. And – I have to repeat – the decision is to keep zope.testrunner
.
Believe me, you won't be the volunteer to do such a migration, so please do not nag the zopefoundation maintainers: There are more important things to do than changing the test runner.
@kloczek As there is no obvious way to send you a personal message I have to write it here in public: I personally think that most of the issues you created in zopefoundation repositories are not helpful for the projects. It seems that you do want to respect the decisions of the maintainers. Please find a more constructive way to support the zopefoundation projects.
I think that have possibility to use pytest extensions is really constructive.
If it is not clear I'm not asking to drop zope.testrunner
.
Maybe I'm wrong but what I saw I think that it should be possible to have possibility to be able use zope.testrunner
and pytest
.
Tomasz Kłoczko wrote at 2021-9-14 23:53 -0700:
If it is not clear I'm not asking to drop
zope.testrunner
. Maybe I'm wrong but what I saw I think that it should be possible to have possibility to be able usezope.testrunner
andpytest
.
Does pytest
support test layers?
A test layer sets up (and tears down) test infrastructure
shared by a set of tests. This significantly reduces test time
and is important for Zope related tests.
zope.testrunner
supports test layer hierarchies based on
Python's class hiararchy.
Should pytest
does not do so as well, it is in general not
adequat for Zope related tests.
No, pytest
does not support layers
, as I already wrote in https://github.com/zopefoundation/zope.exceptions/issues/21#issuecomment-915844937.
There is https://pypi.org/project/gocept.pytestlayer/ to bring layers into pytest
but it has its own problems because layers
are a concept which is quite different from pytest's fixtures
.
Additionally I see no gain in trying to support two test runners. I see only an increased maintenance burden. pytest
does not solve any problems in zopefoundation
repositories which zope.testrunner
didn't already solve.
I'm trying to package your module as an rpm package. So I'm using the typical build, install and test cycle used on building packages from non-root account.
May I ask for help because few units are failing: