Jonathan Eunice avatar Jonathan Eunice committed 6974a91

started automated testing with tox and py.test; confirmed operational under many versions of Python; extended tests

Comments (0)

Files changed (6)

 *.swp.{py,txt,html,css,js}
 *.pyc
 .DS_Store
+.tox
 build/*
 dist/*
 *.egg-info
 The more I use singleton classes in Python as designated special values, the more
 useful they seem.
 
+Recent Changes
+==============
+
+ * Commenced automated mutli-version testing with
+   `pytest <http://pypi.python.org/pypi/pytest>`_
+   and `tox <http://pypi.python.org/pypi/tox>`_. Versions later than 0.4 
+   successfully test against Python 2.5, 2.6, 2.7, 3.2, and 3.3.
+
 Installation
 ============
 
+[pytest]
+python_files = test/*.py
 
 setup(
     name='textdata',
-    version=verno("0.018"),
+    version=verno("0.401"),
     author='Jonathan Eunice',
     author_email='jonathan.eunice@gmail.com',
     description='Get clean line or text data from multi-line strings',
     url='https://bitbucket.org/jeunice/textdata',
     py_modules=['textdata'],
     install_requires=[],
+    tests_require = ['tox', 'pytest'],
+    zip_safe = True,
+    keywords='text data lines',
     classifiers=[
         'Development Status :: 3 - Alpha',
         'Operating System :: OS Independent',
         'License :: OSI Approved :: BSD License',
         'Intended Audience :: Developers',
         'Programming Language :: Python',
+        'Programming Language :: Python :: 2.5',
+        'Programming Language :: Python :: 2.6',
+        'Programming Language :: Python :: 2.7',
+        'Programming Language :: Python :: 3.2',
+        'Programming Language :: Python :: 3.3',
     ]
-)
+)
-
-from testharness import import_from_parent, test_run
-import_from_parent()
 
 from textdata import *
+import sys
 
+def _print(*args, **kwargs):
+    """
+    Python 2 and 3 compatible print function, similar to Python 3 arg handling.
+    """
+    sep = kwargs.get('sep', ' ')
+    end = kwargs.get('end', '\n')
+    f   = kwargs.get('file', sys.stdout)
+    parts = [str(item) for item in args ]
+    parts.append(end)
+    f.write(sep.join(parts))
+    
+    
 def single_trial(name, t, **kwargs):
-    print "---", name, "---"
+    _print("---", name, "---")
     reslines = lines(t, **kwargs)
     for line in reslines:
-        print line
-    print "--- end", name, "---"
+        _print(line)
+    _print("--- end", name, "---")
 
-    print
+    _print()
     
-def test_lines():
-    
+def test_basic():
     
     assert lines("""
                  a
                  or
                  two""") == ['a','line','or','two']
     
-    single_trial('test1', """
+def test_mixed_indent():
+    
+    assert lines("""
     This is a test of lines
     these should all
     be nice and dedented
     because ends with more than one blank line, those will be captured
     
     
-          """, noblanks=False)
+          """) == \
+    ['This is a test of lines',
+     'these should all',
+     'be nice and dedented',
+     '    except this one, which has a little non-common space',
+     'ok?',
+     'because ends with more than one blank line, those will be captured']
+    
+def test_noblanks_false():
+    
+    assert lines("""
+    This is a test of lines
+    these should all
+    be nice and dedented
+        except this one, which has a little non-common space
+    ok?
+    because ends with more than one blank line, those will be captured
+    
+    
+          """, noblanks=False) == \
+    ['This is a test of lines',
+     'these should all',
+     'be nice and dedented',
+     '    except this one, which has a little non-common space',
+     'ok?',
+     'because ends with more than one blank line, those will be captured',
+     '',
+     '']
+    
+def test_extra_start_space():
     
     single_trial('test2', """
                 
       
 
     
-          """)
+          """) == \
+    ['This is a test of lines',
+     'here there should be no blanks',
+     ' but some that start wiht a little extra space ok?',
+     "  which isn't common"]
 
 def test_textlines():
     lresult = lines("""
     
           """)
     
-    assert lresult == tresult.splitlines()
-    
-        
-if __name__ == '__main__':
-    test_run()
-    
+    assert lresult == tresult.splitlines()
+[tox]
+envlist = py25, py26, py27, py32, py33
+
+[testenv]
+deps=pytest
+commands=py.test
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.