eggs/infrae.subversion-1.4.5-py2.6.egg/infrae/subversion/tests/test_impl.py
changeset 69 c6bca38c1cbf
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 ## -*- coding: utf-8 -*-
       
     2 
       
     3 __author__ = "sylvain@infrae.com"
       
     4 __format__ = "plaintext"
       
     5 __version__ = "$Id: test_impl.py 31670 2008-10-31 10:21:14Z sylvain $"
       
     6 
       
     7 import doctest
       
     8 import os
       
     9 import os.path
       
    10 import sys
       
    11 import unittest
       
    12 from doctest import DocFileSuite
       
    13 
       
    14 import py
       
    15 import svnhelper.testing
       
    16 import svnhelper.tests
       
    17 import zc.buildout.testing
       
    18 from svnhelper.core import helper
       
    19 
       
    20 import infrae.subversion
       
    21 
       
    22 
       
    23 def setUp(test):
       
    24     test_package = os.path.dirname(svnhelper.tests.__file__)
       
    25     test_package = os.path.join(test_package, 'tests', 'my.testing')
       
    26     tested_package = os.path.dirname(infrae.subversion.__file__)
       
    27 
       
    28     zc.buildout.testing.buildoutSetUp(test)
       
    29     zc.buildout.testing.install('py', test)
       
    30     zc.buildout.testing.install_develop('infrae.subversion', test)
       
    31     svnhelper.testing.setUpRepository(test)
       
    32     test.globs['init_test_package'](test_package)
       
    33     helper.import_to(test_package,
       
    34                      test.globs['repository'])
       
    35     helper.import_to(tested_package,
       
    36                      test.globs['repository'] + '/infrae.subversion/trunk/infrae.subversion')
       
    37 
       
    38 def tearDown(test):
       
    39     svnhelper.testing.tearDownRepository(test)
       
    40     zc.buildout.testing.buildoutTearDown(test)
       
    41 
       
    42 flags = (doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE |
       
    43          doctest.REPORT_ONLY_FIRST_FAILURE | doctest.REPORT_NDIFF)
       
    44 
       
    45 def have_pysvn():
       
    46     impl = os.getenv('INFRAE_SUBVERSION_IMPL', 'PYSVN')
       
    47     if impl == 'PYSVN':
       
    48         try:
       
    49             import pysvn
       
    50             return True
       
    51         except:
       
    52             pass
       
    53     return False
       
    54 
       
    55 def test_file(name):
       
    56     return os.path.join(os.path.dirname(__file__), name)
       
    57 
       
    58 def test_suite():
       
    59     tests = [DocFileSuite(test_file('IMPL.txt'),
       
    60                           optionflags=flags,
       
    61                           globs=globals(),
       
    62                           setUp=setUp,
       
    63                           tearDown=tearDown,
       
    64                           module_relative=False)]
       
    65     if have_pysvn():
       
    66         tests += [DocFileSuite(test_file('EXPORT.txt'),
       
    67                                optionflags=flags,
       
    68                                globs=globals(),
       
    69                                setUp=setUp,
       
    70                                tearDown=tearDown,
       
    71                                module_relative=False)]
       
    72     return unittest.TestSuite(tests)
       
    73 
       
    74 if __name__ == '__main__':
       
    75     unittest.main(defaultTest='test_suite')