make @usedb work correctly
This commit is contained in:
parent
938bbf9bf3
commit
bebe865848
test
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
import unittest
|
||||
|
||||
from nose.tools import raises, eq_
|
||||
@ -18,15 +19,13 @@ class Base(unittest.TestCase):
|
||||
"""Compares two strings that should be\
|
||||
identical except for whitespace
|
||||
"""
|
||||
def createLines(s):
|
||||
s = s.replace(' ', '')
|
||||
lines = s.split('\n')
|
||||
return filter(None, lines)
|
||||
lines1 = createLines(v1)
|
||||
lines2 = createLines(v2)
|
||||
self.assertEquals(len(lines1), len(lines2))
|
||||
for line1, line2 in zip(lines1, lines2):
|
||||
self.assertEquals(line1, line2)
|
||||
def strip_whitespace(s):
|
||||
return re.sub(r'\s', '', s)
|
||||
|
||||
line1 = strip_whitespace(v1)
|
||||
line2 = strip_whitespace(v2)
|
||||
|
||||
self.assertEquals(line1, line2, "%s != %s" % (v1, v2))
|
||||
|
||||
def ignoreErrors(self, func, *p,**k):
|
||||
"""Call a function, ignoring any exceptions"""
|
||||
|
@ -68,15 +68,12 @@ def usedb(supported=None, not_supported=None):
|
||||
|
||||
my_urls = [url for url in urls if is_supported(url, supported, not_supported)]
|
||||
|
||||
def dec(func):
|
||||
def entangle(self):
|
||||
for url in my_urls:
|
||||
self._setup(url)
|
||||
yield func, self
|
||||
self._teardown()
|
||||
entangle.__name__ = func.__name__
|
||||
entangle.__doc__ = func.__doc__
|
||||
return entangle
|
||||
@decorator
|
||||
def dec(f, self, *a, **kw):
|
||||
for url in my_urls:
|
||||
self._setup(url)
|
||||
f(self, *a, **kw)
|
||||
self._teardown()
|
||||
return dec
|
||||
|
||||
|
||||
@ -88,7 +85,7 @@ class DB(Base):
|
||||
|
||||
level = TXN
|
||||
|
||||
def _engineInfo(self,url=None):
|
||||
def _engineInfo(self, url=None):
|
||||
if url is None:
|
||||
url = self.url
|
||||
return url
|
||||
@ -99,7 +96,7 @@ class DB(Base):
|
||||
def _teardown(self):
|
||||
self._disconnect()
|
||||
|
||||
def _connect(self,url):
|
||||
def _connect(self, url):
|
||||
self.url = url
|
||||
self.engine = engines[url]
|
||||
self.meta = MetaData(bind=self.engine)
|
||||
|
@ -9,7 +9,7 @@ from migrate.versioning import exceptions, version
|
||||
from test import fixture
|
||||
|
||||
|
||||
class TestPyScript(fixture.Pathed):
|
||||
class TestPyScript(fixture.Pathed, fixture.DB):
|
||||
cls = PythonScript
|
||||
def test_create(self):
|
||||
"""We can create a migration script"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user