summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/engines.py
Commit message (Collapse)AuthorAgeFilesLines
* Create initial 2.0 engine implementationMike Bayer2020-04-161-2/+5
| | | | | | | | | | | | | | | | | | | Implemented the SQLAlchemy 2 :func:`.future.create_engine` function which is used for forwards compatibility with SQLAlchemy 2. This engine features always-transactional behavior with autobegin. Allow execution options per statement execution. This includes that the before_execute() and after_execute() events now accept an additional dictionary with these options, empty if not passed; a legacy event decorator is added for backwards compatibility which now also emits a deprecation warning. Add some basic tests for execution, transactions, and the new result object. Build out on a new testing fixture that swaps in the future engine completely to start with. Change-Id: I70e7338bb3f0ce22d2f702537d94bb249bd9fb0a Fixes: #4644
* Fix databases -> dialectsMike Bayer2020-04-011-1/+1
| | | | | | | | | The change in I5343a2d270ed5a8c654b9fe13dff40cdf54649ed left the name "databases" present in one spot, which is usually not reached unless tests are being run on only partial files where not every dialect has been imported. Change-Id: I5a8776b412eaf2476f8a93eebc31448b6f9218ee
* Deprecate the databases packagesFederico Caselli2020-02-281-2/+2
| | | | | | | The databases package is an old alias to the dialect package, and its usage is now deprecated Change-Id: I5343a2d270ed5a8c654b9fe13dff40cdf54649ed
* Do away with pool._refsMike Bayer2020-02-011-6/+6
| | | | | | | | | | | | | This collection was added only for the benefit of unit tests and is unnecessary for the pool to function. As SQLAlchemy 2.0 will be removing the automatic handling of connections that are garbage collection, remove this collection so that we ultimately don't need a weakref handler to do anything within the pool. The handler will do nothing other than emit a warning that a connection was dereferenced without being explicitly returned to the pool, invalidated, or detached. Change-Id: I4ca196270d5714efbac44dbf6f034e8c7f0af58a
* Remove jython code, remove all jython / pypy symbolsMike Bayer2020-01-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | Removed all dialect code related to support for Jython and zxJDBC. Jython has not been supported by SQLAlchemy for many years and it is not expected that the current zxJDBC code is at all functional; for the moment it just takes up space and adds confusion by showing up in documentation. At the moment, it appears that Jython has achieved Python 2.7 support in its releases but not Python 3. If Jython were to be supported again, the form it should take is against the Python 3 version of Jython, and the various zxJDBC stubs for various backends should be implemented as a third party dialect. Additionally modernized logic that distinguishes between "cpython" and "pypy" to instead look at platform.python_distribution() which reliably tells us if we are cPython or not; all booleans which previously checked for pypy and sometimes jython are now converted to be "not cpython", this impacts the test suite for tests that are cPython centric. Fixes: #5094 Change-Id: I226cb55827f997daf6b4f4a755c18e7f4eb8d9ad
* happy new yearMike Bayer2020-01-011-1/+1
| | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Source base cleanupsMike Bayer2020-01-011-3/+1
| | | | | | | | | | | | | | | in trying to apply 2020 copyright to files, the pre-commit hooks complain about random file issues. - remove old corrections.py utility, this had something to do with repairing refs in the sphinx docs - run pre commit hooks on all files - formatting adjustments to work around code formatting collisions (long import lines that zimports can't rewrite correctly) Change-Id: I260744866f69e902eb93665c7c728ee94d3371a2
* Remove threadlocal engine strategy, engine strategies pool threadlocalMike Bayer2019-07-151-3/+3
| | | | | | | | | | | | The "threadlocal" execution strategy, deprecated in 1.3, has been removed for 1.4, as well as the concept of "engine strategies" and the ``Engine.contextual_connect`` method. The "strategy='mock'" keyword argument is still accepted for now with a deprecation warning; use :func:`.create_mock_engine` instead for this use case. Fixes: #4632 Change-Id: I8a351f9fa1f7dfa2a56eec1cd2d1a4b9d65765a2 (cherry picked from commit b368c49b44c5716d93c7428ab22b6761c6ca7cf5)
* Add deprecation warnings to all deprecated APIsMike Bayer2019-01-231-0/+3
| | | | | | | | | | | | | | | A large change throughout the library has ensured that all objects, parameters, and behaviors which have been noted as deprecated or legacy now emit ``DeprecationWarning`` warnings when invoked. As the Python 3 interpreter now defaults to displaying deprecation warnings, as well as that modern test suites based on tools like tox and pytest tend to display deprecation warnings, this change should make it easier to note what API features are obsolete. See the notes added to the changelog and migration notes for further details. Fixes: #4393 Change-Id: If0ea11a1fc24f9a8029352eeadfc49a7a54c0a1b
* happy new yearMike Bayer2019-01-111-1/+1
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-061-3/+5
| | | | | | | | | | | | | Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
* Run black -l 79 against all source filesMike Bayer2019-01-061-30/+30
| | | | | | | | | | | | | | This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
* Don't call rollback on DBAPI connection that's "closed"Mike Bayer2018-10-141-0/+6
| | | | | | | | | | Use the existence of ConnectionRecord.connection to estimate that this connection is likely closed, and if so, don't try to call "rollback" on it. This rollback is normally harmless but is causing segfaults in mysqlclient due to https://github.com/PyMySQL/mysqlclient-python/issues/270. Change-Id: I1d7c5f5a520527d8268b6334795c2051f7ceeea6
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* Use config.db global opts as defaults for all testing_engine()Mike Bayer2017-03-221-0/+3
| | | | | | | | | | Some options need to be passed to engines in all cases, such as currently the oracle 12516 workaround. make sure calls to testing_engine also set up the dictionary with defaults even if options is passed. not clear if this affects other backends yet. Change-Id: I5a1f7634e4ce5af6fe55dc21a24db6afacd19bb7
* Integrate "pre-ping" into connection pool.Mike Bayer2017-03-201-3/+19
| | | | | | | | | | | | | | | Added native "pessimistic disconnection" handling to the :class:`.Pool` object. The new parameter :paramref:`.Pool.pre_ping`, available from the engine as :paramref:`.create_engine.pool_pre_ping`, applies an efficient form of the "pre-ping" recipe featured in the pooling documentation, which upon each connection check out, emits a simple statement, typically "SELECT 1", to test the connection for liveness. If the existing connection is no longer able to respond to commands, the connection is transparently recycled, and all other connections made prior to the current timestamp are invalidated. Change-Id: I89700d0075e60abd2250e54b9bd14daf03c71c00 Fixes: #3919
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - repair that we use db_opts when the url here is different,Mike Bayer2015-06-191-3/+8
| | | | as we are using db_opts for the first time with legacy_schema_args
* - repair a regression caused by #3282, where we no longer wereMike Bayer2015-04-221-1/+8
| | | | | | | | | | applying any topological sort to tables on SQLite. See the changelog for details, but we now continue to sort tables for SQLite on DROP, prohibit the sort from considering alter, and only warn if we encounter an unresolvable cycle, in which case, then we forego the ordering. use_alter as always is used to break such a cycle. fixes #3378
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - force the _has_events flag to True on engines, so thatMike Bayer2014-12-081-0/+3
| | | | | profiling is more predictable - restore the profiling from before this change
* - rework the assert_sql system so that we have a context manager to work with,Mike Bayer2014-12-071-3/+0
| | | | use events that are local to the engine and to the run and are removed afterwards.
* Merge branch 'master' into fdbsql-testsScott Dugas2014-11-031-4/+0
|\ | | | | | | | | Conflicts: lib/sqlalchemy/testing/exclusions.py
| * cleanup exception handling - use new exception hierarchy (since python 2.5)pr/140ndparker2014-10-021-4/+0
| |
* | Removed accidental print statementsScott Dugas2014-10-301-2/+0
| |
* | Support additional args/kwargs on cursor methodScott Dugas2014-10-221-4/+6
|/ | | | | fdbsql has an optional nested kwarg, which is supported in the actual code, but not in the testing proxy
* - rework profiling, zoomark tests into single tests so thatMike Bayer2014-08-161-112/+0
| | | | they can be used under xdist
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-18/+19
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-1/+1
| | | | Found using: https://github.com/intgr/topy
* - Support has been added for pytest to run tests. This runnerMike Bayer2014-03-031-18/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | is currently being supported in addition to nose, and will likely be preferred to nose going forward. The nose plugin system used by SQLAlchemy has been split out so that it works under pytest as well. There are no plans to drop support for nose at the moment and we hope that the test suite itself can continue to remain as agnostic of testing platform as possible. See the file README.unittests.rst for updated information on running tests with pytest. The test plugin system has also been enhanced to support running tests against mutiple database URLs at once, by specifying the ``--db`` and/or ``--dburi`` flags multiple times. This does not run the entire test suite for each database, but instead allows test cases that are specific to certain backends make use of that backend as the test is run. When using pytest as the test runner, the system will also run specific test suites multiple times, once for each database, particularly those tests within the "dialect suite". The plan is that the enhanced system will also be used by Alembic, and allow Alembic to run migration operation tests against multiple backends in one run, including third-party backends not included within Alembic itself. Third party dialects and extensions are also encouraged to standardize on SQLAlchemy's test suite as a basis; see the file README.dialects.rst for background on building out from SQLAlchemy's test platform.
* - _cursor_execute() will close the cursor on error; oracle doesn't allow ↵Mike Bayer2014-01-131-2/+2
| | | | | | double close - ensure no iterator changed size issues in testing.engines
* - continue with [ticket:2907] and further clean up how we set upMike Bayer2014-01-131-1/+5
| | | | | | | | | | | | | | _reset_agent, so that it's local to the various begin_impl(), rollback_impl(), etc. this allows setting/resetting of the flag to be symmetric. - don't set _reset_agent if it's not None, don't unset it if it isn't our own transaction. - make sure we clean it out in close(). - basically, we're dealing here with pools using "threadlocal" that have a counter, other various mismatches that the tests bring up - test for recover() now has to invalidate() the previous connection, because closing it actually rolls it back (e.g. this test was relying on the broken behavior).
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - add copyright to source files missing itMike Bayer2013-10-261-1/+7
|
* improve the close handling here so that we don't double-close a connection;Mike Bayer2013-06-281-3/+5
| | | | we log this now so it apparently happens a bunch
* - fdb is now official, [ticket:2504]Mike Bayer2013-06-031-4/+4
| | | | | - restore the rollback cleanup handler, pg8000 is mostly obsolete as a dialect and the firebird drivers need it
* a pass where we try to squash down as many list()/keys() combinationsMike Bayer2013-05-261-22/+20
| | | | as possible
* test_execute up for sqlite, pg, oursql, mysql 2.7 + 3.3Mike Bayer2013-05-041-1/+1
|
* - the raw 2to3 runMike Bayer2013-04-271-21/+22
| | | | - went through examples/ and cleaned out excess list() calls
* mymysql dialectHajime Nakagami2013-03-011-1/+1
|
* just a pep8 pass of lib/sqlalchemy/testing/Diana Clarke2012-11-191-4/+27
|
* - add back __engine_options__Mike Bayer2012-10-041-0/+1
| | | | | - break test_insert tests into explicitly get_lastrowid() vs. implicit_returning tests, fix up requirements to split them out
* - more tests, move some tests out of test_reflection, test_queryMike Bayer2012-09-271-1/+1
|
* trying different approaches to test layout. in this one, the testing modulesMike Bayer2012-09-271-0/+429
become an externally usable package but still remains within the main sqlalchemy parent package. in this system, we use kind of an ugly hack to get the noseplugin imported outside of the "sqlalchemy" package, while still making it available within sqlalchemy for usage by third party libraries.