class TestConfiguration(object):

    def setup(self):
        self.check_call = Mock()
        self.environ = dict(PATH='/usr/bin', __PYVENV_LAUNCHER__='x')
        self.exists = Mock()
        self.rmtree = Mock()
        self.configuration = Configuration(
            python='2.7', variables=dict(A='a', B='x'),
            check_call=self.check_call, environ=self.environ,
            exists=self.exists, rmtree=self.rmtree)

    def test_env_vars_are_set_before_running_a_build(self):
        outer = self

        class B(object):

            def run(self, environ):
                eq_(environ.get('CI'), 'true')
                eq_(environ.get('TRAVIS'), 'true')
                eq_(environ.get('TRAVIS_SOLO'), 'true')

                path_elements = environ.get('PATH', '').split(':')
                ok_(len(path_elements) > 0)
                eq_(path_elements[0], join(
                    outer.configuration.virtualenv_path, 'bin'))
                assert '__PYVENV_LAUNCHER__' not in environ

        build = B()
        self.configuration.run_build(build)
Пример #2
0
class TestConfiguration(object):
    def setup(self):
        self.check_call = Mock()
        self.isdir = Mock()
        self.environ = dict(PATH='/usr/bin', __PYVENV_LAUNCHER__='x')
        self.exists = Mock()
        self.rmtree = Mock()
        self.configuration = Configuration(python='2.7',
                                           variables=dict(A='a', B='x'),
                                           check_call=self.check_call,
                                           isdir=self.isdir,
                                           environ=self.environ,
                                           exists=self.exists,
                                           rmtree=self.rmtree)

    def test_env_vars_are_set_before_running_a_build(self):
        outer = self

        class B(object):
            def run(self, environ):
                eq_(environ.get('CI'), 'true')
                eq_(environ.get('TRAVIS'), 'true')
                eq_(environ.get('TRAVIS_SOLO'), 'true')

                path_elements = environ.get('PATH', '').split(':')
                ok_(len(path_elements) > 0)
                eq_(path_elements[0],
                    join(outer.configuration.virtualenv_path, 'bin'))
                assert '__PYVENV_LAUNCHER__' not in environ

        build = B()
        self.configuration.run_build(build)