Skip to content

Commit

Permalink
Merge 9bcfb6d into 644bd71
Browse files Browse the repository at this point in the history
  • Loading branch information
kedder committed Apr 23, 2020
2 parents 644bd71 + 9bcfb6d commit f5a8bc2
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,5 +1,5 @@
.cache
.coverage
.coverage*
.installed.cfg
.tox
.venv/
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -6,7 +6,8 @@ matrix:
env: TOXENV=py36
- python: 3.7
env: TOXENV=py37
dist: xenial
- python: 3.8
env: TOXENV=py38
install:
- pip install tox-travis coveralls
script:
Expand Down
6 changes: 5 additions & 1 deletion CHANGES.rst
Expand Up @@ -4,7 +4,11 @@ CHANGELOG
1.3.2 (unreleased)
------------------

- Nothing changed yet.
- Add support for Python-3.8

- Drop support for Python-2.7

- Modernize development environment with pipenv


1.3.1 (2019-03-01)
Expand Down
12 changes: 12 additions & 0 deletions Pipfile
@@ -0,0 +1,12 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pytest = "*"
pytest-coverage = "*"
mock = "*"

[packages]
migrant = {editable = true,path = "."}
154 changes: 154 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions README.rst
Expand Up @@ -27,3 +27,19 @@ Features include:
* support for downgrading
* support for out-of-order migrations
* support for migrating multiple homogenuous databases


Development
-----------

To set up development environment, use `pipenv`::

pipenv install --dev

To run tests, use `pytest`::

pytest

To run tests under all supported environments, use `tox`::

tox --skip-missing-interpreters
6 changes: 3 additions & 3 deletions src/migrant/cli.py
Expand Up @@ -7,7 +7,7 @@
import sys
import argparse
import logging
from configparser import SafeConfigParser
from configparser import ConfigParser

from migrant import exceptions
from migrant.engine import MigrantEngine
Expand Down Expand Up @@ -122,9 +122,9 @@ def cmd_status(args, cfg):
def load_config(fname):
if not os.path.exists(fname):
raise exceptions.ConfigurationError("%s is missing" % fname)
cfg = SafeConfigParser()
cfg = ConfigParser()
with open(fname) as cfgfp:
cfg.readfp(cfgfp)
cfg.read_file(cfgfp)
return cfg


Expand Down
4 changes: 2 additions & 2 deletions src/migrant/repository.py
Expand Up @@ -4,10 +4,10 @@
#
###############################################################################
import os
import imp
import logging
import string
import hashlib
from importlib.machinery import SourceFileLoader

try:
from string import maketrans
Expand Down Expand Up @@ -65,7 +65,7 @@ class Script:
def __init__(self, filename):
assert filename.endswith(".py")
self.name = os.path.basename(filename)[:-3]
self.module = imp.load_source(self.name, filename)
self.module = SourceFileLoader(self.name, filename).load_module()

def up(self, db):
self._exec("up", db)
Expand Down
10 changes: 5 additions & 5 deletions src/migrant/tests/test_cli.py
Expand Up @@ -11,7 +11,7 @@
import textwrap
import logging
import pytest
from configparser import SafeConfigParser
from configparser import ConfigParser
import multiprocessing

from migrant import cli, backend, exceptions
Expand Down Expand Up @@ -90,8 +90,8 @@ def on_repo_init(self):

class ConfigTest(unittest.TestCase):
def test_get_db_config(self):
cp = SafeConfigParser()
cp.readfp(io.StringIO(SAMPLE_CONFIG), "SAMPLE_CONFIG")
cp = ConfigParser()
cp.read_file(io.StringIO(SAMPLE_CONFIG), "SAMPLE_CONFIG")
config = cli.get_db_config(cp, "db1")
self.assertEqual(
config,
Expand Down Expand Up @@ -245,8 +245,8 @@ def sample_config(tmpdir):
% tmpdir
)

cfg = SafeConfigParser()
cfg.readfp(io.StringIO(SAMPLE_CONFIG), "SAMPLE_CONFIG")
cfg = ConfigParser()
cfg.read_file(io.StringIO(SAMPLE_CONFIG), "SAMPLE_CONFIG")
return cfg


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist = py27, py36, py37
envlist = py36, py37, py38

[testenv]
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
Expand Down

0 comments on commit f5a8bc2

Please sign in to comment.