예제 #1
0
def main(args=None):
    try:
        config = parseconfig(args, 'tox')
        retcode = Session(config).runcommand()
        raise SystemExit(retcode)
    except KeyboardInterrupt:
        raise SystemExit(2)
예제 #2
0
 def test_summary_status(self, initproj, capfd):
     initproj("logexample123-0.5",
              filedefs={
                  'tests': {
                      'test_hello.py': "def test_hello(): pass"
                  },
                  'tox.ini':
                  '''
         [testenv:hello]
         [testenv:world]
         '''
              })
     config = parseconfig([])
     session = Session(config)
     envlist = ['hello', 'world']
     envs = session.venvlist
     assert len(envs) == 2
     env1, env2 = envs
     session.setenvstatus(env1, "FAIL XYZ")
     assert session.venvstatus[env1.path]
     session.setenvstatus(env2, 0)
     assert not session.venvstatus[env2.path]
     session._summary()
     out, err = capfd.readouterr()
     exp = "%s: FAIL XYZ" % env1.envconfig.envname
     assert exp in out
     exp = "%s: commands succeeded" % env2.envconfig.envname
     assert exp in out
예제 #3
0
def main(args=None):
    try:
        config = parseconfig(args, 'tox')
        retcode = Session(config).runcommand()
        raise SystemExit(retcode)
    except KeyboardInterrupt:
        raise SystemExit(2)
예제 #4
0
파일: conftest.py 프로젝트: pombredanne/tox
 def newconfig(args, source=None):
     if source is None:
         source = args
         args = []
     s = py.std.textwrap.dedent(source)
     p = tmpdir.join("tox.ini")
     p.write(s)
     old = tmpdir.chdir()
     try:
         return parseconfig(args)
     finally:
         old.chdir()
예제 #5
0
def main():
    base_dir = os.path.dirname(os.path.abspath(__file__))
    travis_config_path = os.path.join(base_dir, TRAVIS_CONFIG_FILENAME)
    with open(travis_config_path, 'w') as f:
        print("language: python", file=f)
        print("env:", file=f)
        for env in parseconfig(pkg='tox').envlist:
            print("  - TOX_ENV={}".format(env), file=f)
        print("install:", file=f)
        print("  - pip install tox", file=f)
        print("script:", file=f)
        print("  - tox", file=f)
예제 #6
0
 def newconfig(args, source=None):
     if source is None:
         source = args
         args = []
     s = py.std.textwrap.dedent(source)
     p = tmpdir.join("tox.ini")
     p.write(s)
     old = tmpdir.chdir()
     try:
         return parseconfig(args)
     finally:
         old.chdir()
예제 #7
0
def generate_tox_config(fileobj):
    def print_(text):
        print(text, file=fileobj)

    print_("language: python")
    print_("python: 3.4")
    print_("env:")
    for env in parseconfig(None, "tox").envlist:
        print_("  - TOX_ENV={env}".format(env))
    print_("install:")
    print_("  - pip install tox")
    print_("script:")
    print_("  - tox -e $TOX_ENV")
예제 #8
0
파일: setup.py 프로젝트: rtindru/spyne
    def run_tests(self):
        print("running tests")
        sys.path.append(join(EXAMPLES_DIR, "django"))
        os.environ["DJANGO_SETTINGS_MODULE"] = "rpctest.settings"
        ret = 0
        ret = (
            call_pytest(
                "interface",
                "model",
                "multipython",
                "protocol",
                "test_null_server.py",
                "test_service.py",
                "test_soft_validation.py",
                "test_util.py",
                "test_sqlalchemy.py",
                "test_sqlalchemy_deprecated.py",
                # here we run django tests in the same process
                # for coverage reason
                "interop/test_django.py",
                "interop/test_pyramid.py",
                capture=self.capture,
            )
            or ret
        )
        # test different versions of Django
        # FIXME: better to use tox in CI script
        # For now we run it here
        from tox._config import parseconfig
        from tox._cmdline import Session

        tox_args = ["-ctox.django.ini"]
        config = parseconfig(tox_args, "tox")
        ret = Session(config).runcommand() or ret

        ret = call_pytest_subprocess("interop/test_httprpc.py", capture=self.capture) or ret
        ret = call_pytest_subprocess("interop/test_soap_client_http.py", capture=self.capture) or ret
        ret = call_pytest_subprocess("interop/test_soap_client_zeromq.py", capture=self.capture) or ret
        ret = call_pytest_subprocess("interop/test_suds.py", capture=self.capture) or ret
        ret = (
            call_trial("interop/test_soap_client_http_twisted.py", "transport/test_msgpack.py", capture=self.capture)
            or ret
        )

        if ret == 0:
            print(GREEN + "All that glisters is not gold." + RESET)
        else:
            print(RED + "Something is rotten in the state of Denmark." + RESET)

        raise SystemExit(ret)
예제 #9
0
파일: setup.py 프로젝트: trecouvr/spyne
    def run_tests(self):
        print("running tests")
        sys.path.append(join(EXAMPLES_DIR, 'django'))
        os.environ['DJANGO_SETTINGS_MODULE'] = 'rpctest.settings'
        ret = 0
        ret = call_pytest(
            'interface',
            'model',
            'multipython',
            'protocol',
            'test_null_server.py',
            'test_service.py',
            'test_soft_validation.py',
            'test_util.py',
            'test_sqlalchemy.py',
            'test_sqlalchemy_deprecated.py',
            # here we run django tests in the same process
            # for coverage reason
            'interop/test_django.py',
            'interop/test_pyramid.py',
            capture=self.capture) or ret
        # test different versions of Django
        # FIXME: better to use tox in CI script
        # For now we run it here
        from tox._config import parseconfig
        from tox._cmdline import Session
        tox_args = ['-ctox.django.ini']
        config = parseconfig(tox_args, 'tox')
        ret = Session(config).runcommand() or ret

        ret = call_pytest_subprocess('interop/test_httprpc.py',
                                     capture=self.capture) or ret
        ret = call_pytest_subprocess('interop/test_soap_client_http.py',
                                     capture=self.capture) or ret
        ret = call_pytest_subprocess('interop/test_soap_client_zeromq.py',
                                     capture=self.capture) or ret
        ret = call_pytest_subprocess('interop/test_suds.py',
                                     capture=self.capture) or ret
        ret = call_trial('interop/test_soap_client_http_twisted.py',
                         'transport/test_msgpack.py',
                         capture=self.capture) or ret

        if ret == 0:
            print(GREEN + "All that glisters is not gold." + RESET)
        else:
            print(RED + "Something is rotten in the state of Denmark." + RESET)

        raise SystemExit(ret)
예제 #10
0
 def test_getvenv(self, initproj, capfd):
     initproj("logexample123-0.5", filedefs={
         'tests': {'test_hello.py': "def test_hello(): pass"},
         'tox.ini': '''
         [testenv:hello]
         [testenv:world]
         '''
     })
     config = parseconfig([])
     session = Session(config)
     venv1 = session.getvenv("hello")
     venv2 = session.getvenv("hello")
     assert venv1 is venv2
     venv1 = session.getvenv("world")
     venv2 = session.getvenv("world")
     assert venv1 is venv2
     pytest.raises(LookupError, lambda: session.getvenv("qwe"))
예제 #11
0
 def test_make_sdist_distshare(self, tmpdir, initproj):
     distshare = tmpdir.join("distshare")
     initproj("example123-0.6", filedefs={
         'tests': {'test_hello.py': "def test_hello(): pass"},
         'tox.ini': '''
         [tox]
         distshare=%s
         ''' % distshare
     })
     config = parseconfig([])
     session = Session(config)
     sdist = session.sdist()
     assert sdist.check()
     assert sdist.ext == ".zip"
     assert sdist == config.distdir.join(sdist.basename)
     sdist_share = config.distshare.join(sdist.basename)
     assert sdist_share.check()
     assert sdist_share.read("rb") == sdist.read("rb"), (sdist_share, sdist)
예제 #12
0
 def test_make_sdist(self, initproj):
     initproj("example123-0.5", filedefs={
         'tests': {'test_hello.py': "def test_hello(): pass"},
         'tox.ini': '''
         '''
     })
     config = parseconfig([])
     session = Session(config)
     sdist = session.sdist()
     assert sdist.check()
     assert sdist.ext == ".zip"
     assert sdist == config.distdir.join(sdist.basename)
     sdist2 = session.sdist()
     assert sdist2 == sdist
     sdist.write("hello")
     assert sdist.stat().size < 10
     sdist_new = Session(config).sdist()
     assert sdist_new == sdist
     assert sdist_new.stat().size > 10
예제 #13
0
def mk_travis_config():
    """Generate configuration for travis."""
    t = dedent("""\
        sudo: false
        language: python
        python: 3.4
        env:
        {jobs}
        install:
            - pip install -r requirements/ci.txt
        script:
            - invoke ci_run_job $TOX_JOB
        after_success:
            coveralls
    """)
    jobs = [env for env in parseconfig(None, 'tox').envlist
            if not env.startswith('cov-')]
    jobs += 'coverage',
    print(t.format(jobs=('\n'.join(('    - TOX_JOB=' + job)
                                   for job in jobs))))
예제 #14
0
 def test_getvenv(self, initproj, capfd):
     initproj("logexample123-0.5",
              filedefs={
                  'tests': {
                      'test_hello.py': "def test_hello(): pass"
                  },
                  'tox.ini':
                  '''
         [testenv:hello]
         [testenv:world]
         '''
              })
     config = parseconfig([])
     session = Session(config)
     venv1 = session.getvenv("hello")
     venv2 = session.getvenv("hello")
     assert venv1 is venv2
     venv1 = session.getvenv("world")
     venv2 = session.getvenv("world")
     assert venv1 is venv2
     pytest.raises(LookupError, lambda: session.getvenv("qwe"))
예제 #15
0
 def test_make_sdist(self, initproj):
     initproj("example123-0.5",
              filedefs={
                  'tests': {
                      'test_hello.py': "def test_hello(): pass"
                  },
                  'tox.ini': '''
         '''
              })
     config = parseconfig([])
     session = Session(config)
     sdist = session.sdist()
     assert sdist.check()
     assert sdist.ext == ".zip"
     assert sdist == config.distdir.join(sdist.basename)
     sdist2 = session.sdist()
     assert sdist2 == sdist
     sdist.write("hello")
     assert sdist.stat().size < 10
     sdist_new = Session(config).sdist()
     assert sdist_new == sdist
     assert sdist_new.stat().size > 10
예제 #16
0
 def test_make_sdist_distshare(self, tmpdir, initproj):
     distshare = tmpdir.join("distshare")
     initproj("example123-0.6",
              filedefs={
                  'tests': {
                      'test_hello.py': "def test_hello(): pass"
                  },
                  'tox.ini':
                  '''
         [tox]
         distshare=%s
         ''' % distshare
              })
     config = parseconfig([])
     session = Session(config)
     sdist = session.sdist()
     assert sdist.check()
     assert sdist.ext == ".zip"
     assert sdist == config.distdir.join(sdist.basename)
     sdist_share = config.distshare.join(sdist.basename)
     assert sdist_share.check()
     assert sdist_share.read("rb") == sdist.read("rb"), (sdist_share, sdist)
예제 #17
0
 def test_summary_status(self, initproj, capfd):
     initproj("logexample123-0.5", filedefs={
         'tests': {'test_hello.py': "def test_hello(): pass"},
         'tox.ini': '''
         [testenv:hello]
         [testenv:world]
         '''
     })
     config = parseconfig([])
     session = Session(config)
     envs = session.venvlist
     assert len(envs) == 2
     env1, env2 = envs
     env1.status = "FAIL XYZ"
     assert env1.status
     env2.status = 0
     assert not env2.status
     session._summary()
     out, err = capfd.readouterr()
     exp = "%s: FAIL XYZ" % env1.envconfig.envname
     assert exp in out
     exp = "%s: commands succeeded" % env2.envconfig.envname
     assert exp in out
예제 #18
0
    def test_log_pcall(self, initproj, tmpdir, capfd):
        initproj("logexample123-0.5", filedefs={
            'tests': {'test_hello.py': "def test_hello(): pass"},
            'tox.ini': '''
            '''
        })
        config = parseconfig([])
        session = Session(config)
        assert not session.config.logdir.listdir()
        opts = {}
        capfd.readouterr()
        session.report.popen(["ls", ], log=None, opts=opts)
        out, err = capfd.readouterr()
        assert '0.log' in out
        assert 'stdout' in opts
        assert opts['stdout'].write
        assert opts['stderr'] == py.std.subprocess.STDOUT
        x = opts['stdout'].name
        assert x.startswith(str(session.config.logdir))

        opts={}
        session.report.popen(["ls", ], log=None, opts=opts)
        out, err = capfd.readouterr()
        assert '1.log' in out

        opts={}
        newlogdir = tmpdir.mkdir("newlogdir")
        cwd = newlogdir.dirpath()
        cwd.chdir()
        session.report.popen(["xyz",], log=newlogdir, opts=opts)
        l = newlogdir.listdir()
        assert len(l) == 1
        assert l[0].basename == "0.log"
        out, err = capfd.readouterr()
        relpath = l[0].relto(cwd)
        expect = ">%s%s0.log" % (newlogdir.basename, newlogdir.sep)
        assert expect in out
예제 #19
0
파일: setup.py 프로젝트: timic/spyne
    def run_tests(self):
        print("running tests")
        sys.path.append(join(EXAMPLES_DIR, 'django'))
        os.environ['DJANGO_SETTINGS_MODULE'] = 'rpctest.settings'
        ret = 0
        ret = call_pytest('interface', 'model', 'protocol',
                          'test_null_server.py', 'test_service.py',
                          'test_soft_validation.py', 'test_util.py',
                          'test_sqlalchemy.py',
                          'test_sqlalchemy_deprecated.py',
                          # here we run django tests in the same process
                          # for coverage reason
                          'interop/test_django.py',
                          'interop/test_pyramid.py') or ret
        # test different versions of Django
        # FIXME: better to use tox in CI script
        # For now we run it here
        from tox._config import parseconfig
        from tox._cmdline import Session
        tox_args = []
        config = parseconfig(tox_args, 'tox')
        ret = Session(config).runcommand()

        ret = call_pytest_subprocess('interop/test_httprpc.py') or ret
        ret = call_pytest_subprocess('interop/test_soap_client_http.py') or ret
        ret = call_pytest_subprocess('interop/test_soap_client_zeromq.py') or ret
        ret = call_pytest_subprocess('interop/test_suds.py') or ret
        ret = call_trial('interop/test_soap_client_http_twisted.py',
                         'transport/test_msgpack.py') or ret

        if ret == 0:
            print(GREEN + "All that glisters is not gold." + RESET)
        else:
            print(RED + "Something is rotten in the state of Denmark." + RESET)

        raise SystemExit(ret)
예제 #20
0
#!/usr/bin/env python
from tox._config import parseconfig
from yaml import dump


class TravisFromTox(object):

    def __init__(self, tox_config):
        self._tox_config = tox_config

    def build_travis_dict(self):
        return {
            'language': 'python',
            'install': ['pip install "tox>=1.8.0"'],
            'script': 'tox',
            'env': self._get_environment_variables()
        }

    def _get_environment_variables(self):
        return ['TOXENV={0}'.format(env) for env in self._tox_config.envlist]

    def build_travis_yaml(self):
        return dump(self.build_travis_dict(), default_flow_style=False)


if __name__ == '__main__':
    print TravisFromTox(parseconfig()).build_travis_yaml()
예제 #21
0
#!/usr/bin/env python
from tox._config import parseconfig
from yaml import dump


class TravisFromTox(object):
    def __init__(self, tox_config):
        self._tox_config = tox_config

    def build_travis_dict(self):
        return {
            'language': 'python',
            'install': ['pip install "tox>=1.8.0"'],
            'script': 'tox',
            'env': self._get_environment_variables()
        }

    def _get_environment_variables(self):
        return ['TOXENV={0}'.format(env) for env in self._tox_config.envlist]

    def build_travis_yaml(self):
        return dump(self.build_travis_dict(), default_flow_style=False)


if __name__ == '__main__':
    print TravisFromTox(parseconfig()).build_travis_yaml()
예제 #22
0
import os

os.chdir("..")

from tox._config import parseconfig

print("language: python")
print("python: 2.7")
print("env:")
for env in parseconfig(None, 'tox').envlist:
    print("  - TOX_ENV=%s" % env)
print("install:")
print("  - pip install tox")
print("  - pip install python-coveralls")
print("script:")
print("  - tox -e $TOX_ENV")
print("after_success:")
print('  - if [ "$TOX_ENV" = "py27 ]; then tox -e coveralls; fi')
print("notifications:")
print("  email: false")
예제 #23
0
#!/usr/bin/env python
#  -*- coding: utf-8 -*-
# based heavily on https://www.dominicrodger.com/tox-and-travis.html
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
import os
from tox._config import parseconfig

ENVS = (' - TOX_ENV={value!s}'.format(value=x)
        for x in parseconfig(None, 'tox').envlist)

TEMPLATE = """language: python

sudo: false

notifications:
  email: false

install:
  - pip install --upgrade tox

env:
{envs}

script:
  - tox -e $TOX_ENV
""".format(envs="\n".join(ENVS))

예제 #24
0
import os
os.chdir("..")

from tox._config import parseconfig

print("language: python")
print("python: 2.7")
print("env:")
for env in parseconfig(None, 'tox').envlist:
    print("  - TOX_ENV=%s" % env)
print("install:")
print("  - pip install tox")
print("  - pip install python-coveralls")
print("script:")
print("  - tox -e $TOX_ENV")
print("after_success:")
print('  - if [ "$TOX_ENV" = "py27 ]; then tox -e coveralls; fi')
print("notifications:")
print("  email: false")