Open kloczek opened 2 years ago
Hi,
I think for the first one that sounds reasonable, we could turn the tests
into a package.
But for the second point, I'm not sure what needs to be done, the warnings are clear and telling that you probably are running tests with SQLite. You might want to ignore the warnings?
Hi,
I think for the first one that sounds reasonable, we could turn the
tests
into a package. But for the second point, I'm not sure what needs to be done, the warnings are clear and telling that you probably are running tests with SQLite. You might want to ignore the warnings?
Please dond't get me wrong .. I'm not asking to fix that but more I'm flagging some issue 😄
tests
module .. if that module would have _init.py file it would be possible to use it by run pytest --pargs tests
gentle ping .. just tested new 0.6.0 and looks like issue still is around 😋
Updated pyetst output with two files in --ignore list
platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/databases-0.6.0
plugins: anyio-3.5.0, cov-3.0.0
collected 50 items
tests/test_database_url.py ...... [ 12%]
tests/test_databases.py .............s...............ss.s..s... [ 90%]
tests/test_importer.py ..... [100%]
============================================================================= warnings summary =============================================================================
tests/test_databases.py::test_decimal_field[sqlite:///testsuite]
/home/tkloczko/rpmbuild/BUILDROOT/python-databases-0.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/databases/backends/sqlite.py:100: SAWarning: Dialect sqlite+pysqlite does *not* support Decimal objects natively, and SQLAlchemy must convert from floating point - rounding errors and other issues may occur. Please consider storing Decimal numbers as strings or integers on this platform for lossless storage.
metadata = CursorResultMetaData(context, cursor.description)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================= short test summary info ==========================================================================
SKIPPED [1] tests/test_databases.py:521: Test (currently) only supports asyncpg
SKIPPED [1] tests/test_databases.py:1012: Test requires `pg_sleep()`
SKIPPED [1] tests/test_databases.py:1034: Test requires `pg_sleep()`
SKIPPED [1] tests/test_databases.py:1085: SQLite interface does not work with temporary tables.
SKIPPED [1] tests/test_databases.py:1137: Test is only for asyncpg
================================================================= 45 passed, 5 skipped, 1 warning in 3.32s =================================================================
I forgot about this completely, what would be the fix here? this is the expected behaviour, I'm not sure about the packaging.
Packaging has nothing to do with that issue. That part about packaging is only about context that exactly the same approach/methodology to build and test is working already in case +950 of other packaged python modules.
So what is the issue here? And do you have any suggestions for the fix?
All is alredy in the ticket 😋
Just made quick hack
--- a/tests/test_connection_options.py
+++ b/tests/test_connection_options.py
@@ -8,7 +8,7 @@
from databases.backends.aiopg import AiopgBackend
from databases.backends.postgres import PostgresBackend
from databases.core import DatabaseURL
-from tests.test_databases import DATABASE_URLS, async_adapter
+from test_databases import DATABASE_URLS, async_adapter
if sys.version_info >= (3, 7): # pragma: no cover
from databases.backends.asyncmy import AsyncMyBackend
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -5,7 +5,7 @@
from starlette.testclient import TestClient
from databases import Database, DatabaseURL
-from tests.test_databases import DATABASE_URLS
+from test_databases import DATABASE_URLS
metadata = sqlalchemy.MetaData()
than with above:
usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.3.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/databases-0.7.0
plugins: anyio-3.6.2, cov-4.0.0
collected 51 items / 1 error
========================================================================================== ERRORS ===========================================================================================
_____________________________________________________________________ ERROR collecting tests/test_connection_options.py _____________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/databases-0.7.0/tests/test_connection_options.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.8/site-packages/aiopg/sa/engine.py:11: in <module>
from sqlalchemy.dialects.postgresql.psycopg2 import (
E ImportError: cannot import name 'PGCompiler_psycopg2' from 'sqlalchemy.dialects.postgresql.psycopg2' (/usr/lib64/python3.8/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py)
During handling of the above exception, another exception occurred:
/usr/lib64/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
tests/test_connection_options.py:8: in <module>
from databases.backends.aiopg import AiopgBackend
../../BUILDROOT/python-databases-0.7.0-4.fc35.x86_64/usr/lib/python3.8/site-packages/databases/backends/aiopg.py:8: in <module>
from aiopg.sa.engine import APGCompiler_psycopg2
/usr/lib/python3.8/site-packages/aiopg/sa/__init__.py:3: in <module>
from .engine import Engine, create_engine
/usr/lib/python3.8/site-packages/aiopg/sa/engine.py:16: in <module>
raise ImportError("aiopg.sa requires sqlalchemy")
E ImportError: aiopg.sa requires sqlalchemy
================================================================================== short test summary info ==================================================================================
ERROR tests/test_connection_options.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================== 1 error in 0.52s ======================================================================================
and that with --ignore that files it exposes more issues
The same result without above patch and only with --ignore list
Here is list of installed modules in build env
Gentle ping .. any update? 🤔
Just FTR: updated pytest output for 0.7.0
I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modulesGenerally this ticket is about
databases
tsting methodology 😄Here is raw pytest output:
In this case it cannot be
tests
module from source tree because there is no tests/init.py file (or something is issing).After ignore those two files pytest show one warning