]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Added in Examples into the test suite so they get exercised regularly. Cleaned up...
authorMichael Trier <mtrier@gmail.com>
Mon, 27 Jul 2009 02:12:15 +0000 (02:12 +0000)
committerMichael Trier <mtrier@gmail.com>
Mon, 27 Jul 2009 02:12:15 +0000 (02:12 +0000)
23 files changed:
CHANGES
examples/__init__.py [new file with mode: 0644]
examples/adjacencytree/__init__.py [new file with mode: 0644]
examples/association/__init__.py [new file with mode: 0644]
examples/collections/__init__.py [new file with mode: 0644]
examples/custom_attributes/__init__.py [new file with mode: 0644]
examples/derived_attributes/__init__.py [new file with mode: 0644]
examples/dynamic_dict/__init__.py [new file with mode: 0644]
examples/elementtree/__init__.py [new file with mode: 0644]
examples/elementtree/pickle.py
examples/graphs/__init__.py [new file with mode: 0644]
examples/nested_sets/__init__.py [new file with mode: 0644]
examples/pickle/__init__.py [new file with mode: 0644]
examples/pickle/custom_pickler.py
examples/poly_assoc/__init__.py [new file with mode: 0644]
examples/polymorph/__init__.py [new file with mode: 0644]
examples/polymorph/polymorph.py
examples/postgis/__init__.py [new file with mode: 0644]
examples/query_caching/__init__.py [new file with mode: 0644]
examples/sharding/__init__.py [new file with mode: 0644]
examples/vertical/__init__.py [new file with mode: 0644]
test/ex/__init__.py [new file with mode: 0644]
test/ex/test_examples.py [new file with mode: 0644]

diff --git a/CHANGES b/CHANGES
index a0246dd0b3118766d59d42ffe49b52a3341fdaeb..eeba6f8bffb5aff0ef2a73cc829c5379132dbd82 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -69,6 +69,11 @@ CHANGES
    - Declarative will raise an informative exception if 
      __table_args__ is passed as a tuple with no dict argument.
      Improved documentation.  [ticket:1468]
+
+- test
+   - Added examples into the test suite so they get exercised
+     regularly and cleaned up a couple deprecation warnings.
+
      
 0.5.5
 =======
diff --git a/examples/__init__.py b/examples/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/adjacencytree/__init__.py b/examples/adjacencytree/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/association/__init__.py b/examples/association/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/collections/__init__.py b/examples/collections/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/custom_attributes/__init__.py b/examples/custom_attributes/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/derived_attributes/__init__.py b/examples/derived_attributes/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/dynamic_dict/__init__.py b/examples/dynamic_dict/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/elementtree/__init__.py b/examples/elementtree/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index 220bb2295386a75a1311c597f76514c078ad8ffb..2176512cf1d8c5532987fdb4b72b37f6997a1b7a 100644 (file)
@@ -26,12 +26,17 @@ from xml.etree import ElementTree
 engine = create_engine('sqlite://')
 meta = MetaData(engine)
 
+# setup a comparator for the PickleType since it's a mutable
+# element.
+def are_elements_equal(x, y):
+    return x == y
+
 # stores a top level record of an XML document.  
 # the "element" column will store the ElementTree document as a BLOB.
 documents = Table('documents', meta,
     Column('document_id', Integer, primary_key=True),
     Column('filename', String(30), unique=True),
-    Column('element', PickleType)
+    Column('element', PickleType(comparator=are_elements_equal))
 )
 
 meta.create_all()
diff --git a/examples/graphs/__init__.py b/examples/graphs/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/nested_sets/__init__.py b/examples/nested_sets/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/pickle/__init__.py b/examples/pickle/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index 79a8b3fa393dcc42632187c79371591a8632b69b..a02b708e570ec57186d116f2f2dc0b153950d3c6 100644 (file)
@@ -68,7 +68,13 @@ class Foo(object):
 class Bar(object):
     def __init__(self, value):
         self.data = value
-    
+
+    def __eq__(self, other):
+        if not other is None:
+            return self.data == other.data
+        return NotImplemented
+
+
 mapper(Foo, foo_table, extension=MyExt())
 mapper(Bar, bar_table)
 
diff --git a/examples/poly_assoc/__init__.py b/examples/poly_assoc/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/polymorph/__init__.py b/examples/polymorph/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
index ea56ffed1f36988e726ff2f19c0937e096351447..60ef98f57dc19e1949de30a388a37e858dcd15cf 100644 (file)
@@ -66,7 +66,7 @@ mapper(Company, companies, properties={
     'employees': relation(Person, lazy=False, backref='company', cascade="all, delete-orphan")
 })
 
-session = create_session(echo_uow=False)
+session = create_session()
 c = Company(name='company1')
 c.employees.append(Manager(name='pointy haired boss', status='AAB', manager_name='manager1'))
 c.employees.append(Engineer(name='dilbert', status='BBA', engineer_name='engineer1', primary_language='java'))
diff --git a/examples/postgis/__init__.py b/examples/postgis/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/query_caching/__init__.py b/examples/query_caching/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/sharding/__init__.py b/examples/sharding/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/examples/vertical/__init__.py b/examples/vertical/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/ex/__init__.py b/test/ex/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/ex/test_examples.py b/test/ex/test_examples.py
new file mode 100644 (file)
index 0000000..c31b21e
--- /dev/null
@@ -0,0 +1,46 @@
+from sqlalchemy.test import *
+import os, re
+
+
+def find_py_files(dirs):
+    for dn in dirs:
+        dn = os.path.abspath(dn)
+        for root, dirs, files in os.walk(dn):
+            for r in '.svn', 'CVS', '.git', '.hg':
+                try:
+                    dirs.remove(r)
+                except ValueError:
+                    pass
+
+            pyfiles = [fn for fn in files if fn.endswith('.py')]
+            if not pyfiles:
+                continue
+
+            # Find the root of the packages.
+            packroot = root
+            while 1:
+                if not os.path.exists(os.path.join(packroot, '__init__.py')):
+                    break
+                packroot = os.path.dirname(packroot)
+
+            for fn in pyfiles:
+                yield os.path.join(root[len(packroot)+1:], fn)
+
+def filename_to_module_name(fn):
+    if os.path.basename(fn) == '__init__.py':
+        fn = os.path.dirname(fn)
+    return re.sub('\.py$', '', fn.replace(os.sep, '.'))
+
+def find_modules(*args):
+    for fn in find_py_files(args or ('../examples',)):
+        yield filename_to_module_name(fn)
+
+def check_import(module):
+    __import__(module)
+
+
+class ExamplesTest(TestBase):
+    def test_examples(self):
+        for module in find_modules():
+            check_import.description = module
+            yield check_import, module