Skip to content

sqlalchemy test suite fails when run under a directory called "test" #7045

Closed
@kmod

Description

@kmod

Describe the bug

If you put sqlalchemy in a directory called "test", the test suite will fail. It doesn't have to be the direct parent, it can be an ancestor directory.

To Reproduce

cd /tmp
mkdir test
cd test
git clone https://github.com/sqlalchemy/sqlalchemy
cd sqlalchemy
tox -e py38-sqlite
# fails


### Error

Many errors, ending in:

[snip]
___________________________ ERROR at setup of DeclarativeTest_dynamic.test_alt_name_attr_subclass_relationship_attrset ___________________________
[gw1] linux -- Python 3.8.10 /tmp/test/sqlalchemy/.tox/py38-sqlite/bin/python
Traceback (most recent call last):
File "/tmp/test/sqlalchemy/test/orm/declarative/test_basic.py", line 70, in setup_test
Base = declarative_base(testing.db)
File "/tmp/test/sqlalchemy/.tox/py38-sqlite/lib/python3.8/site-packages/sqlalchemy/orm/decl_api.py", line 462, in declarative_base
util.warn_deprecated_20(
File "/tmp/test/sqlalchemy/.tox/py38-sqlite/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py", line 59, in warn_deprecated_20
_warn_with_version(
File "/tmp/test/sqlalchemy/.tox/py38-sqlite/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py", line 36, in _warn_with_version
_warnings_warn(warn, stacklevel=stacklevel + 1)
File "/tmp/test/sqlalchemy/.tox/py38-sqlite/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 1675, in _warnings_warn
warnings.warn(message, stacklevel=stacklevel + 1)
sqlalchemy.exc.RemovedIn20Warning: The bind argument to declarative_base is deprecated and will be removed in SQLAlchemy 2.0. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
============================================================ short test summary info =============================================================
SKIPPED [50] .tox/py38-sqlite/lib/python3.8/site-packages/sqlalchemy/testing/config.py:205: 'MypyPluginTest' unsupported on any DB implementation 'sqlite(3.31.1)+pysqlite', 'sqlite(3.31.1)+aiosqlite'custom function, custom function
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 25 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! xdist.dsession.Interrupted: stopping after 25 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================== 50 skipped, 25 errors in 19.65s =========================================================
ERROR: InvocationError for command /tmp/test/sqlalchemy/.tox/py38-sqlite/bin/python -m pytest --rootdir . --log-info=sqlalchemy.testing -n4 --max-worker-restart=5 --db sqlite --dbdriver sqlite --dbdriver aiosqlite --nomemory (exited with code 2)
____________________________________________________________________ summary _____________________________________________________________________
ERROR: py38-sqlite: commands failed


### Versions

- OS: Ubuntu
- Python: 3.8.10
- SQLAlchemy: rel_1_9_4
- Database: sqlite
- DBAPI: sqlite


### Additional context

_No response_

Activity

kmod

kmod commented on Sep 17, 2021

@kmod
Author
added
bugSomething isn't working
help wantedExtra attention is needed
and removed
requires triageNew issue that requires categorization
on Sep 17, 2021
zzzeek

zzzeek commented on Sep 17, 2021

@zzzeek
Member

this is likely some bug in tox or how we are using it. pytest alone doesnt have a problem. there's some options that we might be able to forego using like PYTHONUSERSITE but we'd have to research rationale for these etc.

added this to the 1.4.x milestone on Sep 17, 2021
jvanasco

jvanasco commented on Sep 20, 2021

@jvanasco
Member

FWIW, I've seen this happen on a lot of Python projects and testing frameworks. A general rule of thumb I've used for many years is to never place a Python project in a directory with the same name as it's test suite.

sqla-tester

sqla-tester commented on Mar 4, 2022

@sqla-tester
Collaborator

Mike Bayer has proposed a fix for this issue in the main branch:

correct for pytest discovery https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3645

sqla-tester

sqla-tester commented on Mar 4, 2022

@sqla-tester
Collaborator

Mike Bayer has proposed a fix for this issue in the rel_1_4 branch:

correct for pytest discovery https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3646

zzzeek

zzzeek commented on Mar 4, 2022

@zzzeek
Member

not a huge fan of how pytest behaves here

4 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtests

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @zzzeek@jvanasco@kmod@sqla-tester

        Issue actions

          sqlalchemy test suite fails when run under a directory called "test" · Issue #7045 · sqlalchemy/sqlalchemy