Commits

Ronny Pfannschmidt committed bbfd2f2

flake8 cleanup

Comments (0)

Files changed (4)

micromigrate/backend_base.py

                 row['name']: row['checksum']
                 for row in self.run_query(MIGRATIONS_AND_CHECKSUMS)
             }
-
-
-

micromigrate/backend_script.py

     out, ignored = proc.communicate()
     if proc.returncode:
         raise Exception(proc.returncode, out, ignored)
+    return parse_lineoutput(out)
 
-    chunks = out.split('\n\n')
+
+def parse_lineoutput(data):
+    chunks = data.split('\n\n')
     return [
         dict(x.strip().split(' = ') for x in chunk.splitlines())
         for chunk in chunks if chunk.strip()
     ]
 
+
 def runsqlite(dbname, script):
     subprocess.check_call([
         'sqlite3', '-line',
     def __repr__(self):
         return '<scriptbackend %r>' % (self.dbname,)
 
-
     def apply(self, migration):
         script = MIGRATION_SCRIPT.format(migration=migration)
         try:
     def results(self, query, params):
         assert not params, 'params unsupported'
         return runquery(self.dbname, query)
-

micromigrate/migrate.py

 from __future__ import print_function
 from hashlib import sha256
 from collections import namedtuple
-import subprocess
 
 
 class Migration(namedtuple('MigrationBase', 'name checksum sql after')):

testing/test_miromigrate.py

 from micromigrate import migrate as mm
 from micromigrate.backend_script import ScriptBackend
 
+
 @pytest.fixture
 def dbname(request, tmpdir):
     db = tmpdir.join('test.sqlite.db')
             ])
     return db
 
+
 @pytest.fixture
 def db(dbname):
     return ScriptBackend(dbname)
 
+
 def test_parse_migration():
     result = mm.parse_migration("-- migration test")
     assert result.name == 'test'
         -- migration test
         fail
         """)
-    pytest.raises(Exception, db.apply ,migration)
+    pytest.raises(Exception, db.apply, migration)
     state = db.state()
     assert state is None