~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_setup.py

  • Committer: Martin Pool
  • Date: 2006-03-12 15:58:22 UTC
  • mto: This revision was merged to the branch mainline in revision 1611.
  • Revision ID: mbp@sourcefrog.net-20060312155822-94e98ec4d9c0c09a
Clean up test_setup code; avoid possible pipe jam

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import sys
5
5
import subprocess
6
6
import shutil
 
7
from tempfile import TemporaryFile
7
8
 
8
9
from bzrlib.tests import TestCase
9
10
 
13
14
 
14
15
class TestSetup(TestCase):
15
16
 
16
 
    def setUp(self):
17
 
        pass
18
 
 
19
17
    def test_build(self):
20
18
        """ test cmd `python setup.py build`
21
19
        
22
20
        This typically catches new subdirectories which weren't added to setup.py
23
21
        """
24
 
        # run setup.py build as subproces and catch return code
25
 
        p = subprocess.Popen([sys.executable, 'setup.py', 'build'],
26
 
                stdout=subprocess.PIPE, stderr=subprocess.PIPE)
27
 
        s = p.communicate()
28
 
        self.assertEqual(0, p.returncode, '`python setup.py build` fails')
29
 
 
30
 
    def tearDown(self):
31
 
        """ cleanup build directory """
32
 
        if os.path.exists('build'):
33
 
            shutil.rmtree(u'build')
 
22
        self.log('test_build running in %s' % os.getcwd())
 
23
        try:
 
24
            # run setup.py build as subproces and catch return code
 
25
            out_file = TemporaryFile()
 
26
            err_file = TemporaryFile()
 
27
            p = subprocess.Popen([sys.executable, 'setup.py', 'build'],
 
28
                                 stdout=out_file, stderr=err_file)
 
29
            s = p.communicate()
 
30
            self.assertEqual(0, p.returncode, '`python setup.py build` fails')
 
31
        finally:
 
32
            if os.path.exists('build'):
 
33
                shutil.rmtree(u'build')