Ejemplo n.º 1
0
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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
    def test_loading_configurations_with_floating_point(self):
        settings = dict(language='python', python=[2.7, '3.3'])

        configurations = self.loader.load_configurations(settings)

        eq_(configurations, (
            Configuration(python='2.7', variables={}),
            Configuration(python='3.3', variables={}),
        ))
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
    def test_loading_configurations(self):
        settings = dict(language='python',
                        python=['2.7', '3.3'],
                        env=['A=a B="asd qwe x=y"', 'A=b'],
                        matrix=dict(include=[
                            dict(
                                python='2.7',
                                env='A=c',
                            ),
                        ],
                                    exclude=[
                                        dict(
                                            python='3.3',
                                            env='A=a B="asd qwe x=y"',
                                        ),
                                        dict(python='3.3', ),
                                    ],
                                    allow_failures=[
                                        dict(
                                            python='2.7',
                                            env='A=b',
                                        ),
                                    ]))

        configurations = self.loader.load_configurations(settings)

        eq_(configurations, (
            Configuration(python='2.7',
                          variables={
                              'A': 'a',
                              'B': 'asd qwe x=y'
                          }),
            Configuration(python='2.7', variables={'A': 'b'}, can_fail=True),
            Configuration(python='3.3', variables={'A': 'b'}),
            Configuration(python='2.7', variables={'A': 'c'}),
        ))