zopefoundation / transaction

Generic transaction implementation for Python.
Other
70 stars 31 forks source link

3.0.1: pytest warnings #103

Closed kloczek closed 3 years ago

kloczek commented 3 years ago

BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)

What I did:

What I expect to happen:

What actually happened:

What version of Python and Zope/Addons I am using:

jugmac00 commented 3 years ago

Can you please show what you did and what the output was?

kloczek commented 3 years ago

All those detalis exce[opt zope version where in thet outpt (version of the python, command and output)

$ pip list |grep zope
zope.event                    4.2.0
zope.interface                5.4.0
zope.testing                  4.7

below pytest of course started in source tree root directory

+ /usr/bin/python3 -Bm pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.9, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
Using --randomly-seed=3115815990
rootdir: /home/tkloczko/rpmbuild/BUILD/transaction-3.0.1
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, httpbin-1.0.0, xdist-2.2.1, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, pyfakefs-4.4.0, freezegun-0.4.2, cases-3.4.6, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, asyncio-0.15.1, toolbox-0.5, xprocess-0.17.1, aiohttp-0.3.0, checkdocs-2.7.0, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, Faker-8.4.0, cov-2.12.1, randomly-3.8.0, hypothesis-6.13.12
collected 179 items

src/transaction/tests/test__manager.py ............................................................                                                                  [ 33%]
. .                                                                                                                                                                  [ 34%]
src/transaction/tests/test__manager.py ....                                                                                                                          [ 36%]
src/transaction/tests/test_savepoint.py ..                                                                                                                           [ 37%]
src/transaction/tests/test__transaction.py .......................................................................................................                   [ 95%]
src/transaction/tests/test_weakset.py ........                                                                                                                       [100%]

============================================================================= warnings summary =============================================================================
src/transaction/tests/test__manager.py:942
  /home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/src/transaction/tests/test__manager.py:942: PytestCollectionWarning: cannot collect test class 'TestTxnException' because it has a __init__ constructor (from: src/transaction/tests/test__manager.py)
    class TestTxnException(Exception):

src/transaction/tests/test__transaction.py::TransactionTests::test_user_w_none
  /home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/src/transaction/tests/test__transaction.py:1346: DeprecationWarning: Expected text
    txn.user = b'phreddy'

-- Docs: https://docs.pytest.org/en/stable/warnings.html
===================================================================== 178 passed, 2 warnings in 7.18s ======================================================================
jugmac00 commented 3 years ago

Hi @kloczek,

about your first deprecation warning: we do not support arbitrary test runners.

Please run the tests, after checking out the source code from GitHub, via tox.

If you want to contribute a PR, which fixes the pytest deprecation warning, without creating problems for our test setup, I'd happily accept it.

I am not sure about the second deprecation warning - it does not show with our test setup:

src/transaction/tests/test__transaction.py::TransactionTests::test_user_w_none
  /home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/src/transaction/tests/test__transaction.py:1346: DeprecationWarning: Expected text
    txn.user = b'phreddy

I am not sure why our test suite is not showing this warning.

FWIW the warning is raised by our own code, which was changed like 4 years ago. So it does not seem to be an urgent problem. I am not even sure, whether this needs to be fixed, or whether we explicitly test providing binary data.

Somebody else should look at the deprecation warning.

kloczek commented 3 years ago

I am not sure why our test suite is not showing this warning.

Ha .. because I'm usimg pytest with buch of plugins which are listed on top of the pytest output. tox is using pytest as backend to tun it in virtenv with exact set of modules. Somerimes it is really good to install few pytest extensions and use directly pytest instad tox. Because I'm building my packages in dedicated build crearted only to build exact package and nothing more so from that point of view I don't need tox second virtual env wrapping, and this caused thay in my packages I have:

[tkloczko@barrel SPECS]$ echo "tox:    $(grep %tox python*|wc -l)"; echo "pytest: $(grep %pytest python*|wc -l)"; echo; echo "$(ls -1 python*|wc -l) python packages"
tox:    21
pytest: 308

441 python packages

However I have as well special type of test build for all packages which are usimg pytest in rpm spec file in %check to try to build those packages with All™️ pytest extensions🤪 I'm using tox only in those cases when pytest for somereson goes on /dev/tree and ends with some errors which are false positive.

icemac commented 3 years ago

tox does not always use pytest internally to run the tests. You can specify the test commands in tox.ini, here we use https://github.com/zopefoundation/transaction/blob/7b9ec6601be223b5bb8f77805e2ee85ef4bd28d2/tox.ini#L24-L26

I am closing this issue now as pytest is not the test runner to be used for this project.

mgedmin commented 3 years ago

I am not sure about the second deprecation warning - it does not show with our test setup:

Are you sure? Because I see it when I run tox with no arguments:

py27 run-test: commands[0] | zope-testrunner --test-path=src -vc
Running tests at level 1
Running zope.testrunner.layer.UnitTests tests:
  Set up zope.testrunner.layer.UnitTests in 0.000 seconds.
  Running:
...................................................................................................................................................................../home/mg/src/zopefoundation/transaction/src/transaction/tests/test__transaction.py:1346: DeprecationWarning: Expected text
  txn.user = b'phreddy'
...........
  Ran 176 tests with 0 failures, 0 errors, 0 skipped in 0.028 seconds.
Tearing down left over layers:
  Tear down zope.testrunner.layer.UnitTests in 0.000 seconds.

Should be fixed by #105.

jugmac00 commented 3 years ago

I am not sure about the second deprecation warning - it does not show with our test setup:

Are you sure? Because I see it when I run tox with no arguments:

Awesome - I must have looked somewhere else!

kloczek commented 2 years ago

Just tested 191607ec and I still se one warning

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-transaction-3.0.1-8.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-transaction-3.0.1-8.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra ==================================================================== test session starts ===================================================================== platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/transaction-3.0.1 collected 177 items src/transaction/tests/test__manager.py ................................................................ [ 36%] src/transaction/tests/test__transaction.py ....................................................................................................... [ 94%] src/transaction/tests/test_savepoint.py .. [ 95%] src/transaction/tests/test_weakset.py ........ [100%] ====================================================================== warnings summary ====================================================================== src/transaction/tests/test__manager.py:942 /home/tkloczko/rpmbuild/BUILD/transaction-3.0.1/src/transaction/tests/test__manager.py:942: PytestCollectionWarning: cannot collect test class 'TestTxnException' because it has a __init__ constructor (from: src/transaction/tests/test__manager.py) class TestTxnException(Exception): -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =============================================================== 177 passed, 1 warning in 0.37s =============================================================== ```