diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-12-31 15:01:50 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-12-31 15:01:50 -0500 |
commit | 410898a56bee5d8dac411e806423fa63dda0d441 (patch) | |
tree | ee7db25b0367432f21d5cfcf8adaa1d2448f8511 /tests/__init__.py | |
parent | 158dea527a00050d008e2d78ddd1ef5765b482f4 (diff) | |
download | alembic-410898a56bee5d8dac411e806423fa63dda0d441.tar.gz |
- The :class:`.ScriptDirectory` system that loads migration files
from a ``versions/`` directory now supports so-called
"sourceless" operation, where the ``.py`` files are not present
and instead ``.pyc`` or ``.pyo`` files are directly present where
the ``.py`` files should be. Note that while Python 3.3 has a
new system of locating ``.pyc``/``.pyo`` files within a directory
called ``__pycache__`` (e.g. PEP-3147), PEP-3147 maintains
support for the "source-less imports" use case, where the
``.pyc``/``.pyo`` are in present in the "old" location, e.g. next
to the ``.py`` file; this is the usage that's supported even when
running Python3.3. #163
Diffstat (limited to 'tests/__init__.py')
-rw-r--r-- | tests/__init__.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/__init__.py b/tests/__init__.py index 904ee76..ad5b033 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -318,7 +318,7 @@ def clear_staging_env(): shutil.rmtree(staging_directory, True) -def write_script(scriptdir, rev_id, content, encoding='ascii'): +def write_script(scriptdir, rev_id, content, encoding='ascii', sourceless=False): old = scriptdir._revision_map[rev_id] path = old.path @@ -338,6 +338,17 @@ def write_script(scriptdir, rev_id, content, encoding='ascii'): scriptdir._revision_map[script.revision] = script script.nextrev = old.nextrev + if sourceless: + # note that if -O is set, you'd see pyo files here, + # the pyc util function looks at sys.flags.optimize to handle this + assert os.access(pyc_path, os.F_OK) + # look for a non-pep3147 path here. + # if not present, need to copy from __pycache__ + simple_pyc_path = util.simple_pyc_file_from_path(path) + if not os.access(simple_pyc_path, os.F_OK): + shutil.copyfile(pyc_path, simple_pyc_path) + os.unlink(path) + def three_rev_fixture(cfg): a = util.rev_id() |