Commits

Jonathan Eunice committed 703bc03

added IsInstance

Comments (0)

Files changed (5)

 syntax: glob
 *.swp.{py,txt,html,css,js}
 *.pyc
+.tox
 .DS_Store
 build/*
 dist/*
         
     def __contains__(self, item):
         return fnmatch.fnmatch(item, self.pattern)
-    
+
+class IsInstance(IntensionalSet):
+    """
+    An object is in an IsInstance if it is an instance of the given types.
+    """
+    def __init__(self, *args):
+        self.types = tuple(args)
+        
+    def __contains__(self, item):
+        return isinstance(item, self.types)
     
 class Any(IntensionalSet):
     """
     An item is in an Any if it is or is in any member of the set.
     """
-    
     def __init__(self, *args):
         self.items = set(args)
         
     """
     An item is in an Every if it is or is in every member of the set.
     """
-    
     def __init__(self, *args):
         self.items = set(args)
 
     """
     An item is in a ButNot if it's in the primary set and not the exclusion.
     """
-    
     def __init__(self, items, exclusion):
         self.items = items
         self.exclusion = exclusion
             return False
         
 class Test(IntensionalSet):
-    
+    """
+    Test is a generic wrapper around lambda expressions.
+    Provides special support for compact, neat expressions by not
+    auto-adding a 'lambda x:' prefix if test provided as a string.
+    """
     def __init__(self, expr, *args, **kwargs):
         IntensionalSet.__init__(self)
         self.args = args
+[pytest]
+python_files = test/*.py
+
 
 setup(
     name='intensional',
-    version=verno("0.101"),
+    version=verno("0.103"),
     author='Jonathan Eunice',
     author_email='jonathan.eunice@gmail.com',
     description='Intensional sets in Python',
+[tox]
+envlist = py26, py27
+
+
+[testenv]
+changedir=test
+deps=pytest       # install pytest in the venvs
+commands=py.test {posargs}