Esempio n. 1
0
def _flake():
    """Test flake8"""
    orig_dir = os.getcwd()
    import_dir, dev = _get_import_dir()
    os.chdir(op.join(import_dir, '..'))
    if dev:
        sys.argv[1:] = ['vispy', 'examples', 'make']
    else:
        sys.argv[1:] = [op.basename(import_dir)]
    sys.argv.append('--ignore=E226,E241,E265,E266,W291,W293,W503')
    sys.argv.append('--exclude=six.py,ordereddict.py,glfw.py,'
                    '_proxy.py,_es2.py,_gl2.py,_pyopengl2.py,'
                    '_constants.py,png.py,decorator.py,ipy_inputhook.py,'
                    'experimental,wiki,_old,mplexporter.py,cubehelix.py')
    try:
        from flake8.main import main
    except ImportError:
        print('Skipping flake8 test, flake8 not installed')
    else:
        print('Running flake8... ')  # if end='', first error gets ugly
        sys.stdout.flush()
        try:
            main()
        except SystemExit as ex:
            if ex.code in (None, 0):
                pass  # do not exit yet, we want to print a success msg
            else:
                raise RuntimeError('flake8 failed')
    finally:
        os.chdir(orig_dir)
Esempio n. 2
0
def _flake():
    """Test flake8"""
    orig_dir = os.getcwd()
    root_dir, dev = _get_root_dir()
    os.chdir(root_dir)
    if dev:
        sys.argv[1:] = ['vispy', 'examples', 'make']
    else:
        sys.argv[1:] = ['vispy']
    sys.argv.append('--ignore=E226,E241,E265,W291,W293')
    sys.argv.append('--exclude=six.py,py24_ordereddict.py,glfw.py,'
                    '_proxy.py,_angle.py,_desktop.py,_pyopengl.py,'
                    '_constants.py,png.py,decorator.py')
    try:
        from flake8.main import main
    except ImportError:
        print('Skipping flake8 test, flake8 not installed')
    else:
        print('Running flake8... ')  # if end='', first error gets ugly
        sys.stdout.flush()
        try:
            main()
        except SystemExit as ex:
            if ex.code in (None, 0):
                pass  # do not exit yet, we want to print a success msg
            else:
                raise RuntimeError('flake8 failed')
    finally:
        os.chdir(orig_dir)
Esempio n. 3
0
def _flake():
    """Test flake8"""
    orig_dir = os.getcwd()
    import_dir, dev = _get_import_dir()
    os.chdir(op.join(import_dir, '..'))
    if dev:
        sys.argv[1:] = ['vispy', 'examples', 'make']
    else:
        sys.argv[1:] = [op.basename(import_dir)]
    try:
        try:
            from flake8.main import main
        except ImportError:
            from flake8.main.cli import main
    except ImportError:
        print('Skipping flake8 test, flake8 not installed')
    else:
        print('Running flake8... ')  # if end='', first error gets ugly
        sys.stdout.flush()
        try:
            main()
        except SystemExit as ex:
            if ex.code in (None, 0):
                pass  # do not exit yet, we want to print a success msg
            else:
                raise RuntimeError('flake8 failed')
    finally:
        os.chdir(orig_dir)
Esempio n. 4
0
def _flake():
    """Test flake8"""
    orig_dir = os.getcwd()
    import_dir, dev = _get_import_dir()
    os.chdir(op.join(import_dir, '..'))
    if dev:
        sys.argv[1:] = ['vispy', 'examples', 'make']
    else:
        sys.argv[1:] = [op.basename(import_dir)]
    try:
        try:
            from flake8.main import main
        except ImportError:
            from flake8.main.cli import main
    except ImportError:
        print('Skipping flake8 test, flake8 not installed')
    else:
        print('Running flake8... ')  # if end='', first error gets ugly
        sys.stdout.flush()
        try:
            main()
        except SystemExit as ex:
            if ex.code in (None, 0):
                pass  # do not exit yet, we want to print a success msg
            else:
                raise RuntimeError('flake8 failed')
    finally:
        os.chdir(orig_dir)
Esempio n. 5
0
def _flake():
    """Test flake8"""
    orig_dir = os.getcwd()
    import_dir, dev = _get_import_dir()
    os.chdir(op.join(import_dir, '..'))
    if dev:
        sys.argv[1:] = ['vispy', 'examples', 'make']
    else:
        sys.argv[1:] = [op.basename(import_dir)]
    sys.argv.append('--ignore=E226,E241,E265,E266,W291,W293,W503')
    sys.argv.append('--exclude=six.py,ordereddict.py,glfw.py,'
                    '_proxy.py,_es2.py,_gl2.py,_pyopengl2.py,'
                    '_constants.py,png.py,decorator.py,ipy_inputhook.py,'
                    'experimental,wiki,_old,mplexporter.py,cubehelix.py,'
                    'cassowary')
    try:
        from flake8.main import main
    except ImportError:
        print('Skipping flake8 test, flake8 not installed')
    else:
        print('Running flake8... ')  # if end='', first error gets ugly
        sys.stdout.flush()
        try:
            main()
        except SystemExit as ex:
            if ex.code in (None, 0):
                pass  # do not exit yet, we want to print a success msg
            else:
                raise RuntimeError('flake8 failed')
    finally:
        os.chdir(orig_dir)
Esempio n. 6
0
def lint():
    from flake8 import main as flake8
    import sys

    click.echo('Running Linter\n{}'.format('=' * 70))
    sys.argv = ['flake8', APP_FOLDER]
    flake8.main()
Esempio n. 7
0
def _flake():
    """Test flake8"""
    orig_dir = os.getcwd()
    root_dir, dev = _get_root_dir()
    os.chdir(root_dir)
    if dev:
        sys.argv[1:] = ['vispy', 'examples', 'make']
    else:
        sys.argv[1:] = ['vispy']
    sys.argv.append('--ignore=E226,E241,E265,W291,W293')
    sys.argv.append('--exclude=six.py,py24_ordereddict.py,glfw.py,'
                    '_proxy.py,_angle.py,_desktop.py,_pyopengl.py,'
                    '_constants.py')
    try:
        from flake8.main import main
    except ImportError:
        print('Skipping flake8 test, flake8 not installed')
    else:
        print('Running flake8... ')  # if end='', first error gets ugly
        sys.stdout.flush()
        try:
            main()
        except SystemExit as ex:
            if ex.code in (None, 0):
                pass  # do not exit yet, we want to print a success msg
            else:
                raise RuntimeError('flake8 failed')
    finally:
        os.chdir(orig_dir)
Esempio n. 8
0
File: make.py Progetto: ggoret/vispy
 def flake(self, arg):
     """ Run flake8 to find style inconsistencies. """
     os.chdir(ROOT_DIR)
     sys.argv[1:] = ['vispy', 'examples', 'make']
     try:
         from flake8.main import main
     except ImportError:
         print('Skipping flake8 test, flake8 not installed')
     else:
         main()
Esempio n. 9
0
def lint(all, stats):
    """Run the linter."""
    from flake8 import main as flake8
    import sys

    if all:
        click.echo('Running linter (including skeleton code).')
        sys.argv = ['flake8', '.']
    else:
        click.echo('Running Linter...')
        sys.argv = ['flake8', APP_FOLDER]

    if stats:
        sys.argv.extend(['--statistics', '-qq'])

    flake8.main()
Esempio n. 10
0
def lint(all, stats):
    """Run the linter."""
    from flake8 import main as flake8
    import sys

    if all:
        click.echo('Running linter (including skeleton code).')
        sys.argv = ['flake8', '.']
    else:
        click.echo('Running Linter...')
        sys.argv = ['flake8', APP_FOLDER]

    if stats:
        sys.argv.extend(['--statistics', '-qq'])

    flake8.main()
Esempio n. 11
0
File: make.py Progetto: kif/vispy
 def flake(self, arg):
     """ Run flake8 to find style inconsistencies. """
     os.chdir(ROOT_DIR)
     sys.argv[1:] = ['vispy', 'examples', 'make']
     try:
         from flake8.main import main
     except ImportError:
         print('Skipping flake8 test, flake8 not installed')
     else:
         print('Running flake8... ')  # if end='', first error gets ugly
         sys.stdout.flush()
         try:
             main()
         except SystemExit as ex:
             if ex.code in (None, 0):
                 pass  # do not exit yet, we want to print a success msg
             else:
                 raise  # raises SystemExit again
         print('Hooray! flake8 test passed.')
Esempio n. 12
0
def _test_style(filename, ignore):
    """ Test style for a certain file.
    """
    if isinstance(ignore, (list, tuple)):
        ignore = ','.join(ignore)
    
    orig_dir = os.getcwd()
    orig_argv = sys.argv
    
    os.chdir(ROOT_DIR)
    sys.argv[1:] = [filename]
    sys.argv.append('--ignore=' + ignore)
    try:
        from flake8.main import main
        main()
    except SystemExit as ex:
        if ex.code in (None, 0):
            return False
        else:
            return True
    finally:
        os.chdir(orig_dir)
        sys.argv[:] = orig_argv
Esempio n. 13
0
def _test_style(filename, ignore):
    """ Test style for a certain file.
    """
    if isinstance(ignore, (list, tuple)):
        ignore = ','.join(ignore)

    orig_dir = os.getcwd()
    orig_argv = sys.argv

    os.chdir(ROOT_DIR)
    sys.argv[1:] = [filename]
    sys.argv.append('--ignore=' + ignore)
    try:
        from flake8.main import main
        main()
    except SystemExit as ex:
        if ex.code in (None, 0):
            return False
        else:
            return True
    finally:
        os.chdir(orig_dir)
        sys.argv[:] = orig_argv
Esempio n. 14
0
def test_code_style():
    try:
        sys.argv = []
        main()
    except SystemExit:
        raise AssertionError('flake8 found code style issues.')
Esempio n. 15
0
from flake8.main import main
# python -m flake8 (with Python >= 2.7)
main()
Esempio n. 16
0
def lint():
    """Runs flake8."""

    sys.argv = [None, '.']
    flake8.main()
Esempio n. 17
0
File: run.py Progetto: 2070616d/TP3
"""
Implementation of the command-line I{flake8} tool.
"""
from flake8.hooks import git_hook, hg_hook                      # noqa
from flake8.main import check_code, check_file, Flake8Command   # noqa
from flake8.main import main


if __name__ == '__main__':
    main()
Esempio n. 18
0
from flake8.main import main

# python -m flake8 (with Python >= 2.7)
main()
Esempio n. 19
0
 def test_flake(self, arg):
     """ Run flake8 to find style inconsistencies. """
     os.chdir(ROOT_DIR)
     sys.argv[1:] = ['vispy', 'examples', 'make']
     from flake8.main import main
     main()
Esempio n. 20
0
"""
Implementation of the command-line I{flake8} tool.
"""
from flake8.hooks import git_hook, hg_hook                      # noqa
from flake8.main import check_code, check_file, Flake8Command   # noqa
from flake8.main import main

if __name__ == '__main__':
    main()
Esempio n. 21
0
            print("- Running", fullname)
            result = doctest.testfile(fullname, module_relative=False)
            print("  => ran {0} results, {1} failed".format(
                result.attempted, result.failed))
            exit_code += result.failed
        elif os.path.isdir(fullname):
            exit_code += run_doctests(fullname)

    return exit_code


if __name__ == "__main__":
    try:
        from flake8 import main as flake8
        sys.argv.append(os.path.dirname(__file__))
        flake8.main()
    except (ImportError, SystemExit):
        pass

    exit_code = 0

    print("========================================")
    print("Running Unittests")
    print("========================================")
    result = unittest.TextTestRunner(verbosity=2).run(tests)
    if not result.wasSuccessful():
        exit_code = 1

    print("========================================")
    print("Running Doctests")
    print("========================================")
Esempio n. 22
0
 def test_flake(self, arg):
     """ Run flake8 to find style inconsistencies. """
     os.chdir(ROOT_DIR)
     sys.argv[1:] = ['vispy', 'examples', 'make']
     from flake8.main import main
     main()
Esempio n. 23
0
        fullname = os.path.join(testsdir, filename)
        if filename.endswith('.doctest'):
            print("- Running", fullname)
            result = doctest.testfile(fullname, module_relative=False)
            print("  => ran {0} results, {1} failed".format(result.attempted, result.failed))
            exit_code += result.failed
        elif os.path.isdir(fullname):
            exit_code += run_doctests(fullname)

    return exit_code

if __name__ == "__main__":
    try:
        from flake8 import main as flake8
        sys.argv.append(os.path.dirname(__file__))
        flake8.main()
    except (ImportError, SystemExit):
        pass

    exit_code = 0

    print("========================================")
    print("Running Unittests")
    print("========================================")
    result = unittest.TextTestRunner(verbosity=2).run(tests)
    if not result.wasSuccessful():
        exit_code = 1

    print("========================================")
    print("Running Doctests")
    print("========================================")