0001# Copyright (C) 2006 Kumar McMillan
0002
0003# This library is free software; you can redistribute it and/or
0004# modify it under the terms of the GNU Lesser General Public
0005# License as published by the Free Software Foundation; either
0006# version 2.1 of the License, or (at your option) any later version.
0007
0008"""Tools for controlling test environments.
0009
0010It provides: 
0011
0012- `testtools.fixtures` -- an abstract interface for installing and reading 
0013  tabular data;
0014- `testtools.io` -- tools for setting up and tearing down I/O environments;
0015- and `testtools.stubs` -- a sparse set of tools for stubbing objects.
0016
0017This package came to life while developing real test suites for applications 
0018and libraries, so nothing has been added here that wasn't necessary for some 
0019task or another.  
0020
0021In my own experience with testing, it pays to get as close to the real world 
0022as possible.  I try to use stub or mock objects only as a last resort, for 
0023optimization, etc.  Thus, the crux of this package is the `fixtures` 
0024module -- it provides the means to load mock data into a real database 
0025(or any storage medium).  
0026
0027Patches are welcome, preferably with tests ;)  The current project is being 
0028trac'ed at http://testtools.python-hosting.com/ and the development code is
0029available here:
0030
0031http://svn.testtools.python-hosting.com/trunk#egg=testtools-dev
0032
0033See docs on each individual module for examples and usage.
0034
0035"""
0036
0037__trunk_version__ = '0.7.8' # current version in trunk
0038
0039__all__ = [ 'fixtures', 'io', 'stubs', 'storage', 'config',
0040            'exceptions', '__version__', ]
0041__repos_url__ = '$HeadURL: https://svn.testtools.python-hosting.com/tags/0.7.8/testtools/__init__.py $'
0042
0043import sre
0044
0045_ver_pattern = sre.compile('(?:branches|tags)/([^/]+)/')
0046
0047def release_version(repos_url = __repos_url__):
0048    """get a release version string based on the 
0049    branch/tag in the repos url for this file
0050    
0051    """
0052    m = _ver_pattern.search(repos_url)
0053    if m:
0054        return m.group(1)
0055    else:
0056        return __trunk_version__
0057
0058__version__ = release_version()