Exemplo n.º 1
0
def test(ctx, unit=False, installed=False, style=False, cover=False):
    """ run tests (unit, style)
    """

    from imageio import testing

    if not (unit or installed or style or cover):
        sys.exit("Test task needs --unit, --style or --cover")

    if unit:
        sys.exit(testing.test_unit())

    if style:
        flake8_wrapper()  # exits on fail
        black_wrapper(False)  # always exits

    if installed:
        for p in list(sys.path):
            if p in ("", "."):
                sys.path.remove(p)
            elif p == ROOT_DIR or p == os.path.dirname(ROOT_DIR):
                sys.path.remove(p)
        os.environ["IMAGEIO_NO_INTERNET"] = "1"
        sys.exit(testing.test_unit())

    if cover:
        res = testing.test_unit(cov_report="html")
        if res:
            raise RuntimeError("Cannot show coverage, tests failed.")
        print("Launching browser.")
        fname = os.path.join(os.getcwd(), "htmlcov", "index.html")
        if not os.path.isfile(fname):
            raise IOError("Generated file not found: %s" % fname)
        webbrowser.open_new_tab(fname)
Exemplo n.º 2
0
def test(ctx, unit=False, installed=False, style=False, cover=False):
    """ run tests (unit, style)
    """

    from imageio import testing

    if not (unit or installed or style or cover):
        sys.exit("Test task needs --unit, --style or --cover")

    if unit:
        sys.exit(testing.test_unit())

    if style:
        flake8_wrapper()  # exits on fail
        black_wrapper(False)  # always exits

    if installed:
        for p in list(sys.path):
            if p in ("", "."):
                sys.path.remove(p)
            elif p == ROOT_DIR or p == os.path.dirname(ROOT_DIR):
                sys.path.remove(p)
        os.environ["IMAGEIO_NO_INTERNET"] = "1"
        sys.exit(testing.test_unit())

    if cover:
        res = testing.test_unit(cov_report="html")
        if res:
            raise RuntimeError("Cannot show coverage, tests failed.")
        print("Launching browser.")
        fname = os.path.join(os.getcwd(), "htmlcov", "index.html")
        if not os.path.isfile(fname):
            raise IOError("Generated file not found: %s" % fname)
        webbrowser.open_new_tab(fname)
Exemplo n.º 3
0
 def test(self, arg):
     """ Run tests:
             * unit - run unit tests
             * style - flake style testing (PEP8 and more)
             * cover - show coverage html report
     """
     if not arg:
         return self.help('test')
     from imageio import testing
     
     if arg in ('flake', 'style'):
         try:
             testing.test_style()
         except RuntimeError as err:
             sys.exit(str(err))
         
     elif arg == 'unit':
         sys.exit(testing.test_unit())
     
     elif arg == 'cover':
         res = testing.test_unit(cov_report='html')
         if res:
             raise RuntimeError('Cannot show coverage, tests failed.')
         print('Launching browser.')
         fname = op.join(os.getcwd(), 'htmlcov', 'index.html')
         if not op.isfile(fname):
             raise IOError('Generated file not found: %s' % fname)
         webbrowser.open_new_tab(fname)
     
     else:
         raise RuntimeError('Invalid arg for make test: %r' % arg)
Exemplo n.º 4
0
 def test(self, arg):
     """ Run tests:
             * unit - run unit tests
             * installed - run unit tests using installed version
             * style - flake style testing (PEP8 and more)
             * cover - show coverage html report
             
     """
     if not arg:
         return self.help('test')
     
     from imageio import testing
     
     if arg in ('flake', 'style'):
         try:
             testing.test_style()
         except RuntimeError as err:
             sys.exit(str(err))
     
     elif arg == 'unit':
         sys.exit(testing.test_unit())
     
     elif arg == 'installed':
         # Like unit, but give preference to installed package.
         # And do not allow the use of an internet connection.
         for p in list(sys.path):
             if p in ('', '.'):
                 sys.path.remove(p)
             elif p == ROOT_DIR or p == os.path.dirname(ROOT_DIR):
                 sys.path.remove(p)
         os.environ['IMAGEIO_NO_INTERNET'] = '1'
         sys.exit(testing.test_unit())
     
     elif arg == 'cover':
         res = testing.test_unit(cov_report='html')
         if res:
             raise RuntimeError('Cannot show coverage, tests failed.')
         print('Launching browser.')
         fname = op.join(os.getcwd(), 'htmlcov', 'index.html')
         if not op.isfile(fname):
             raise IOError('Generated file not found: %s' % fname)
         webbrowser.open_new_tab(fname)
     
     else:
         raise RuntimeError('Invalid arg for make test: %r' % arg)
Exemplo n.º 5
0
 def test(self, arg):
     """ Run tests:
             * unit - run unit tests
             * installed - run unit tests using installed version
             * style - flake style testing (PEP8 and more)
             * cover - show coverage html report
             
     """
     if not arg:
         return self.help('test')
     
     from imageio import testing
     
     if arg in ('flake', 'style'):
         try:
             testing.test_style()
         except RuntimeError as err:
             sys.exit(str(err))
     
     elif arg == 'unit':
         sys.exit(testing.test_unit())
     
     elif arg == 'installed':
         # Like unit, but give preference to installed package.
         # And do not allow the use of an internet connection.
         for p in list(sys.path):
             if p in ('', '.'):
                 sys.path.remove(p)
             elif p == ROOT_DIR or p == os.path.dirname(ROOT_DIR):
                 sys.path.remove(p)
         os.environ['IMAGEIO_NO_INTERNET'] = '1'
         sys.exit(testing.test_unit())
     
     elif arg == 'cover':
         res = testing.test_unit(cov_report='html')
         if res:
             raise RuntimeError('Cannot show coverage, tests failed.')
         print('Launching browser.')
         fname = op.join(os.getcwd(), 'htmlcov', 'index.html')
         if not op.isfile(fname):
             raise IOError('Generated file not found: %s' % fname)
         webbrowser.open_new_tab(fname)
     
     else:
         raise RuntimeError('Invalid arg for make test: %r' % arg)
Exemplo n.º 6
0
def test(ctx, unit=False, installed=False, style=False, cover=False):
    """ run tests (unit, style)
    """

    from imageio import testing

    if not (unit or installed or style or cover):
        sys.exit('Test task needs --unit, --style or --cover')

    if unit:
        sys.exit(testing.test_unit())

    if style:
        try:
            testing.test_style()
        except RuntimeError as err:
            print(str(err))
            sys.exit(1)

    if installed:
        for p in list(sys.path):
            if p in ('', '.'):
                sys.path.remove(p)
            elif p == ROOT_DIR or p == os.path.dirname(ROOT_DIR):
                sys.path.remove(p)
        os.environ['IMAGEIO_NO_INTERNET'] = '1'
        sys.exit(testing.test_unit())

    if cover:
        res = testing.test_unit(cov_report='html')
        if res:
            raise RuntimeError('Cannot show coverage, tests failed.')
        print('Launching browser.')
        fname = os.path.join(os.getcwd(), 'htmlcov', 'index.html')
        if not os.path.isfile(fname):
            raise IOError('Generated file not found: %s' % fname)
        webbrowser.open_new_tab(fname)
Exemplo n.º 7
0
def test(ctx, unit=False, installed=False, style=False, cover=False):
    """ run tests (unit, style)
    """
    
    from imageio import testing
    
    if not (unit or installed or style or cover):
        sys.exit('Test task needs --unit, --style or --cover')
    
    if unit:
        sys.exit(testing.test_unit())
    
    if style:
        try:
            testing.test_style()
        except RuntimeError as err:
            print(str(err))
            sys.exit(1)
    
    if installed:
        for p in list(sys.path):
            if p in ('', '.'):
                sys.path.remove(p)
            elif p == ROOT_DIR or p == os.path.dirname(ROOT_DIR):
                sys.path.remove(p)
        os.environ['IMAGEIO_NO_INTERNET'] = '1'
        sys.exit(testing.test_unit())
    
    if cover:
        res = testing.test_unit(cov_report='html')
        if res:
            raise RuntimeError('Cannot show coverage, tests failed.')
        print('Launching browser.')
        fname = os.path.join(os.getcwd(), 'htmlcov', 'index.html')
        if not os.path.isfile(fname):
            raise IOError('Generated file not found: %s' % fname)
        webbrowser.open_new_tab(fname)
Exemplo n.º 8
0
    def run(self):
        from imageio import testing

        os.environ["IMAGEIO_NO_INTERNET"] = "1"  # run tests without inet
        sys.exit(testing.test_unit())
Exemplo n.º 9
0
 def run(self):
     from imageio import testing
     os.environ['IMAGEIO_NO_INTERNET'] = '1'  # run tests without inet
     sys.exit(testing.test_unit())