summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/fixtures.py
Commit message (Collapse)AuthorAgeFilesLines
...
* Establish future behavior for Session cascade backrefs, bindMike Bayer2020-08-011-7/+8
| | | | | | | | | | | | | | | | | | | | The behavior of the :paramref:`_orm.relationship.cascade_backrefs` flag will be reversed in 2.0 and set to ``False`` unconditionally, such that backrefs don't cascade save-update operations from a forwards-assignment to a backwards assignment. A 2.0 deprecation warning is emitted when the parameter is left at its default of ``True`` at the point at which such a cascade operation actually takes place. The new behavior can be established as always by setting the flag to ``False`` on a specific :func:`_orm.relationship`, or more generally can be set up across the board by setting the the :paramref:`_orm.Session.future` flag to True. Additionally in the interests of expediency, this commit will also move Session away from making use of bound metadata if the future=True flag is set. An application that sets future=True should ideally have to change as little else as possible for full 2.0 behavior. Fixes: #5150 Change-Id: I490d1d61f09c62ffc2de983208aeed25dfe48aec
* Merge "Added reflection method :meth:`.Inspector.get_sequence_names`"mike bayer2020-06-191-0/+4
|\
| * Added reflection method :meth:`.Inspector.get_sequence_names`Federico Caselli2020-06-031-0/+4
| | | | | | | | | | | | | | | | | | | | Added new reflection method :meth:`.Inspector.get_sequence_names` which returns all the sequences defined. Support for this method has been added to the backend that support :class:`.Sequence`: PostgreSql, Oracle, MSSQL and MariaDB >= 10.3. Fixes: #2056 Change-Id: I0949696a39aa28c849edf2504779241f7443778a
* | Warn when transaction context manager ends on inactive transactionMike Bayer2020-06-121-1/+2
|/ | | | | | | | | | if .rollback() or .commit() is called inside the transaction context manager, the transaction object is deactivated. the context manager continues but will not be able to correctly fulfill it's closing state. Ensure a warning is emitted when this happens. Change-Id: I8fc3a73f7c21575dda5bcbd6fb74ddb679771630
* Warn when sorted_tables is not actually sortingMike Bayer2020-05-071-2/+15
| | | | | | | | | | | | | | | A warning is emitted when making use of the :attr:`.MetaData.sorted_tables` attribute as well as the :func:`_schema.sort_tables` function, and the given tables cannot be correctly sorted due to a cyclic dependency between foreign key constraints. In this case, the functions will no longer sort the involved tables by foreign key, and a warning will be emitted. Other tables that are not part of the cycle will still be returned in dependency order. Previously, the sorted_table routines would return a collection that would unconditionally omit all foreign keys when a cycle was detected, and no warning was emitted. Fixes: #5316 Change-Id: I14f72ccf39cb568bc77e8da16d0685718b2b9960
* Propose Result as immediate replacement for ResultProxyMike Bayer2020-05-011-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As progress is made on the _future.Result, including breaking it out such that DBAPI behaviors are local to specific implementations, it becomes apparent that the Result object is a functional superset of ResultProxy and that basic operations like fetchone(), fetchall(), and fetchmany() behave pretty much exactly the same way on the new object. Reorganize things so that ResultProxy is now referred to as LegacyCursorResult, which subclasses CursorResult that represents the DBAPI-cursor version of Result, making use of a multiple inheritance pattern so that the functionality of Result is also available in non-DBAPI contexts, as will be necessary for some ORM patterns. Additionally propose the composition system for Result that will form the basis for ORM-alternative result systems such as horizontal sharding and dogpile cache. As ORM results will soon be coming directly from instances of Result, these extensions will instead build their own ResultFetchStrategies that perform the special steps to create composed or cached result sets. Also considering at the moment not emitting deprecation warnings for fetchXYZ() methods; the immediate issue is Keystone tests are calling upon it, but as the implementations here are proving to be not in any kind of conflict with how Result works, there's not too much issue leaving them around and deprecating at some later point. References: #5087 References: #4395 Fixes: #4959 Change-Id: I8091919d45421e3f53029b8660427f844fee0228
* Rename py.test to pytestGord Thompson2020-04-161-1/+1
| | | | Change-Id: I431e1ef41e26d490343204a75a5c097768749768
* Create initial 2.0 engine implementationMike Bayer2020-04-161-0/+23
| | | | | | | | | | | | | | | | | | | 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
* Pass connection to TablesTest.insert_data()Mike Bayer2020-04-151-3/+5
| | | | | | | | | | towards the goal of reducing verbosity and repetition in test fixtures as well as that we are moving to connection only for execution, move the insert_data() classmethod to accept a connection and adjust all fixtures to use it. Change-Id: I3bf534acca0d5f4cda1d4da8ae91f1155b829b09
* Apply fix to ComputedReflectionFixtureTestGord Thompson2020-04-041-20/+24
| | | | | | | | Avoid errors for dialects without schema support. Also fix typo in test name. Fixes: #5230 Change-Id: Id0f759b591a6119069b0fc5fc3b02addb85b0597
* Support inspection of computed columnFederico Caselli2020-03-151-0/+77
| | | | | | | | | | | | | | | | | | | Added support for reflection of "computed" columns, which are now returned as part of the structure returned by :meth:`.Inspector.get_columns`. When reflecting full :class:`.Table` objects, computed columns will be represented using the :class:`.Computed` construct. Also improve the documentation in :meth:`Inspector.get_columns`, correctly listing all the returned keys. Fixes: #5063 Fixes: #4051 Closes: #5064 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5064 Pull-request-sha: ba00fc321ce468f8885aad23b3dd33c789e50fbe Change-Id: I789986554fc8ac7f084270474d0b2c12046b1cc2
* Replace engine.execute w/ context manager (step1)Gord Thompson2020-02-171-0/+26
| | | | | | | | | First (baby) step at replacing engine.execute calls in test code with the new preferred way of executing. MSSQL was targeted because it was the easiest for me to test locally. Change-Id: Id2e02f0e39007cbfd28ca6a535115f53c6407015
* Remove return statement in __init__.Heckad2020-01-041-1/+1
|
* happy new yearMike Bayer2020-01-011-1/+1
| | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Don't clear metadata in TablesTest setupMike Bayer2019-11-261-5/+8
| | | | | | | | | Some upcoming commits will make use of @metadata_fixture within a TablesTest class. As the fixture takes place before setup, remove anything in setup that would interfere with it. Change-Id: I4f16889c4c02cb2835dcf4886eb09ece848d8109 References: I507bc405eee6cae2c5991345d0eac53a37fe7512
* Generalize DescriptorProps.uses_objectsMike Bayer2019-11-231-1/+4
| | | | | | | | | | | | | | | | Previously, uses_objects was specific to the SynonymAttribute; generalize it so that it defaults to False for other DescriptorProps. Immediate fix is against CompositeProperty. Fixed regression introduced in 1.3.0 related to the association proxy refactor in :ticket:`4351` that prevented :func:`.composite` attributes from working in terms of an association proxy that references them. Add test coverage for association proxies that refer to Composite attributes as endpoints. Fixes: #5000 Change-Id: Iea6fb1bd3314d861a9bc22491b0ae1e6c5e6340d
* - fix typoHeckad2019-10-191-1/+1
|
* Add standalone orm.close_all method and deprecate SessionMaker.close_allAugustin Trancart2019-01-121-2/+2
| | | | | | | | | | | | | | | Added a new function :func:`.close_all_sessions` which takes over the task of the :meth:`.Session.close_all` method, which is now deprecated as this is confusing as a classmethod. Pull request courtesy Augustin Trancart. Fixes: #4412 Closes: #4438 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4438 Pull-request-sha: 7833d12a9898c82d50716427144bf3276c22ab3f Change-Id: Ib35eaa520ae886f3f8f550f9712fc3b139e00b60
* happy new yearMike Bayer2019-01-111-1/+1
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-061-9/+12
| | | | | | | | | | | | | 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-40/+45
| | | | | | | | | | | | | | 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
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* Deactivate transaction if rollback failsMike Bayer2017-08-221-2/+2
| | | | | | | | | | | | Fixed regression introduced in 1.2.0b1 due to :ticket:`3934` where the :class:`.Session` would fail to "deactivate" the transaction, if a rollback failed (the target issue is when MySQL loses track of a SAVEPOINT). This would cause a subsequent call to :meth:`.Session.rollback` to raise an error a second time, rather than completing and bringing the :class:`.Session` back to ACTIVE. Fixes: #4050 Change-Id: Id245e8dd3487cb006b2d6631c8bd513b5ce81abe
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - support declarativemappedtest with per-test setupMike Bayer2015-11-251-0/+10
|
* - Add a new le_() assertion for less than or equalsMike Bayer2015-06-141-7/+8
| | | | | - fix TablesTest to use the bind that we've returned from setup_bind() to emit DELETE statements
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - rework assertsql system, fixes #3293Mike Bayer2015-01-181-3/+2
|
* - proof of concept for parallel testingMike Bayer2014-07-251-13/+5
|
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-4/+7
| | | | 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
* - Support has been added for pytest to run tests. This runnerMike Bayer2014-03-031-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* - Added a new feature which allows automated naming conventions to beMike Bayer2014-02-011-0/+18
| | | | | | | | | | | | | | | | applied to :class:`.Constraint` and :class:`.Index` objects. Based on a recipe in the wiki, the new feature uses schema-events to set up names as various schema objects are associated with each other. The events then expose a configuration system through a new argument :paramref:`.MetaData.naming_convention`. This system allows production of both simple and custom naming schemes for constraints and indexes on a per-:class:`.MetaData` basis. [ticket:2923] commit 7e65e52c086652de3dd3303c723f98f09af54db8 Author: Mike Bayer <mike_mp@zzzcomputing.com> Date: Sat Feb 1 15:09:04 2014 -0500 - first pass at new naming approach
* - repair the fixture/test here to make sure state isn't left over causing ↵Mike Bayer2014-01-271-1/+1
| | | | other tests to fail
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - add copyright to source files missing itMike Bayer2013-10-261-0/+6
|
* - endless isinstance(x, str)s....Mike Bayer2013-04-281-5/+7
|
* - the raw 2to3 runMike Bayer2013-04-271-8/+8
| | | | - went through examples/ and cleaned out excess list() calls
* just a pep8 pass of lib/sqlalchemy/testing/Diana Clarke2012-11-191-2/+13
|
* - don't call get_lastrowid() on explicit returningMike Bayer2012-10-041-1/+0
| | | | | | - don't hardwire "subqueries" requirement in the base, mysql < 4.1 isn't working anyway - don't need explicit FB/PG exclusions in test_returning - hit db.connect() for the returning requirement
* trying different approaches to test layout. in this one, the testing modulesMike Bayer2012-09-271-0/+334
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.