summaryrefslogtreecommitdiff
path: root/tests/test_environment.py
Commit message (Collapse)AuthorAgeFilesLines
* run pyupgradeMike Bayer2022-11-261-1/+0
| | | | | | | | | | | | | | | | | | command is: find alembic -name "*.py" | xargs pyupgrade --py37-plus --keep-runtime-typing --keep-percent-format I'm having some weird fighting with the tools/write_pyi, where in different runtime contexts it keeps losing "MigrationContext" and also Callable drops the args, but it's not consisistent. For whatever reason, under py311 things *do* work every time. im working w/ clean tox environments so not really sure what the change is. anyway, let's at least fix the quoting up around the types. This is towards getting the "*" in the op signatures for #1130. Change-Id: I9175905d3b4325e03a97d6752356b70be20e9fad
* Implement "test suite"Gord Thompson2021-06-181-315/+0
| | | | | Fixes: #855 Change-Id: I11386597d9f3a260d7349b58d276b44d78642a6a
* Ensure proxy transaction still present on exit before closingMike Bayer2021-04-171-0/+28
| | | | | | | | | | | Fixed regression caused by the SQLAlchemy 1.4/2.0 compatibility switch where calling ``.rollback()`` or ``.commit()`` explicitly within the ``context.begin_transaction()`` context manager would cause it to fail when the block ended, as it did not expect that the transaction was manually closed. Change-Id: I4c5ba368bfd480d186276cd75edaac5019130bc6 Fixes: #829
* Implement sys_path_prepend optionMike Bayer2021-02-201-0/+45
| | | | | | | | | | | | | | | Added new config file option ``prepend_sys_path``, which is a series of paths that will be prepended to sys.path; the default value in newly generated alembic.ini files is ".". This fixes a long-standing issue where for some reason running the alembic command line would not place the local "." path in sys.path, meaning an application locally present in "." and importable through normal channels, e.g. python interpreter, pytest, etc. would not be located by Alembic, even though the ``env.py`` file is loaded relative to the current path when ``alembic.ini`` contains a relative path. Change-Id: If8f4279bd862acca44d46f4b1ab90b0a18098af3 Fixes: #797
* Accommodate SQLAlchemy 1.4/2.0CaselIT2021-01-111-18/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | To accommodate SQLAlchemy 1.4 and 2.0, the migration model now no longer assumes that the SQLAlchemy Connection will autocommit an individual operation. This essentially means that for databases that use non-transactional DDL (pysqlite current driver behavior, MySQL), there is still a BEGIN/COMMIT block that will surround each individual migration. Databases that support transactional DDL should continue to have the same flow, either per migration or per-entire run, depending on the value of the :paramref:`.Environment.configure.transaction_per_migration` flag. Compatibility is established such that the entire library should not generate any SQLAlchemy 2.0 deprecation warnings and SQLALCHEMY_WARN_20 is part of conftest.py. (one warning remains for the moment that needs to be resolved on the SQLAlchemy side) The test suite requires SQLAlchemy 1.4.0b2 for testing 1.4; 1.4.0b1 won't work. Test suite / setup also being modernized, as we are at SQLAlchemy 1.3 we can now remove the majority of the testing suite plugin. Change-Id: If55b1ea3c12ead66405ab3fadc76d15d89dabb90
* Remove support for Python 3.5 and SQLAlchemy older than the 1.3 series.CaselIT2020-10-261-1/+0
| | | | | Fixes: #748 Change-Id: I18df97bdce5de6adb222d3f16486272e95b1b1a6
* Support sqlalchemy 1.4 exec_driver_sql, text() for stringsCaselIT2020-03-181-0/+4
| | | | | | | | | | | Adjusted tests so that only connection-explicit execution is used, along with the use of text() for string invocation. Tests that are testing explicitly for deprecation warnings will bypass SQLAlchemy warnings. Added the RemovedIn20 warning as an error raise for these two specific deprecation cases. Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: I4f6b83366329aa95204522c9e99129021d1899fc
* Add autocommit_blockMike Bayer2019-09-171-0/+293
| | | | | | | | | | | | Added new feature :meth:`.MigrationContext.autocommit_block`, a special directive which will provide for a non-transactional block inside of a migration script. The feature requres that: the database driver (e.g. DBAPI) supports the AUTOCOMMIT isolation mode. The directive also necessarily needs to COMMIT the existing transaction in progress in order to enter autocommit mode. Change-Id: I107fe9772595db189b6ebeba6535ac8f275b3fe5 Fixes: #123
* Use SQLAlchemy's testing framework fullyMike Bayer2019-07-211-7/+5
| | | | | | | w/ 1.1 as the minimum version we should be able to remove the majority of the testing suite code Change-Id: I04c4ab45e2ce47f20613d6111895c6230b946f76
* Add dialect_options to environment; set paramstyle=named for offlineMike Bayer2019-07-211-1/+32
| | | | | | | | | | | | | | Fixed bug where the double-percent logic applied to some dialects such as psycopg2 would be rendered in ``--sql`` mode, by allowing dialect options to be passed through to the dialect used to generate SQL and then providing ``paramstyle="named"`` so that percent signs need not be doubled. For users having this issue, existing env.py scripts need to add ``dialect_opts={"paramstyle": "named"}`` to their offline context.configure(). See the ``alembic/templates/generic/env.py`` template for an example. Change-Id: Ia6a495704b029eaff43fb3b6df602ca667002b7a Fixes: #562
* zimports runMike Bayer2019-01-061-12/+12
| | | | | | | after black is applied, rewrite imports and fix remaining whitespace / identifier issues. Change-Id: I49474c085b5f4a4b52e4cf90c9705d6a896d4003
* pure black run + flake8Mike Bayer2019-01-061-39/+27
| | | | | | | run black -l 79 against source code, set up for full flake8 testing. Change-Id: I4108e1274d49894b9898ec5bd3a1147933a473d7
* Warn on non-Connection present and accommodate for EngineMike Bayer2017-03-041-2/+46
| | | | | | | | | | | | | | A warning is emitted when an object that's not a :class:`~sqlalchemy.engine.Connection` is passed to :meth:`.EnvironmentContext.configure`. For the case of a :class:`~sqlalchemy.engine.Engine` passed, the check for "in transaction" introduced in version 0.9.0 has been relaxed to work in the case of an attribute error, as some users appear to be passing an :class:`~sqlalchemy.engine.Engine` and not a :class:`~sqlalchemy.engine.Connection`. Change-Id: I95ef38955c00511d3055362a03284fb91677595f Fixes: #419
* devMike Bayer2014-09-131-5/+6
|
* - finish flake8 on testsMike Bayer2014-09-091-1/+2
|
* - do an autopep8 pass for just about everything otherMike Bayer2014-09-091-0/+2
| | | | than line length
* - changelog + test for MigrationContext.configMike Bayer2014-05-251-2/+10
|
* - Fixed bug where :meth:`.EnvironmentContext.get_x_argument`Mike Bayer2014-04-041-0/+64
would fail if the :class:`.Config` in use didn't actually originate from a command line call. fixes #195