Exemple #1
0
def test_reading_from_url():
    
    icon = Icon('https://assets-cdn.github.com/favicon.ico')
    assert len(icon.image_sizes()) > 0
    
    # Write locally
    icon.write(os.path.join(tempdir, 'gh.ico'))
    icon.write(os.path.join(tempdir, 'gh.icns'))
Exemple #2
0
def test_reading_from_url():
    
    icon = Icon('https://assets-cdn.github.com/favicon.ico')
    assert len(icon.image_sizes()) > 0
    
    # Write locally
    icon.write(os.path.join(tempdir, 'gh.ico'))
    icon.write(os.path.join(tempdir, 'gh.icns'))
Exemple #3
0
def test_export():
    
    # Test using some icons over which I have some control
    B = 'https://raw.githubusercontent.com/pyzo/pyzo/master/pyzo/resources/appicons/'
    
    for name in ['pyzologo', 'py']:
        icon = Icon(B + name + '.ico')
        assert len(icon.image_sizes()) > 0
        
        # Export png
        filename = os.path.join(tempdir, name + '.png')
        icon.write(filename)
        for i in icon.image_sizes():
            assert os.path.isfile(os.path.join(tempdir, name + '%i.png' % i))
        
        # Export bmp
        filename = os.path.join(tempdir, name + '.bmp')
        icon.write(filename)
        for i in icon.image_sizes():
            assert os.path.isfile(os.path.join(tempdir, name + '%i.bmp' % i))
        
        # Failures ..
        
        with raises(TypeError):
            icon.write(3)
        
        with raises(TypeError):
            icon.write([])
        
        if sys.version_info[0] > 2:
            with raises(TypeError):
                icon.write(filename.encode())
        
        with raises(ValueError):
            icon.write(os.path.join(tempdir, name + '.foo'))
Exemple #4
0
def test_export():
    
    # Test using some icons over which I have some control
    B = 'https://bitbucket.org/iep-project/iep/raw/tip/iep/resources/appicons/'
    
    for name in ['ieplogo', 'py']:
        icon = Icon(B + name + '.ico')
        assert len(icon.image_sizes()) > 0
        
        # Export png
        filename = os.path.join(tempdir, name + '.png')
        icon.write(filename)
        for i in icon.image_sizes():
            assert os.path.isfile(os.path.join(tempdir, name + '%i.png' % i))
        
        # Export bmp
        filename = os.path.join(tempdir, name + '.bmp')
        icon.write(filename)
        for i in icon.image_sizes():
            assert os.path.isfile(os.path.join(tempdir, name + '%i.bmp' % i))
        
        # Failures ..
        
        with raises(TypeError):
            icon.write(3)
        
        with raises(TypeError):
            icon.write([])
        
        if sys.version_info[0] > 2:
            with raises(TypeError):
                icon.write(filename.encode())
        
        with raises(ValueError):
            icon.write(os.path.join(tempdir, name + '.foo'))