예제 #1
0
def IsUrlEqual(url_or_path_1, url_or_path_2):
    '''
    :param str url_or_path_1:

    :param str url_or_path_2:

    :rtype: bool
    :returns:
        True if Url's are equal.

        Ignores case if url protocol is 'file' in a Windows machine (Windows ignores case for local
        directories).
    '''
    from urlparse import urlparse

    protocol = urlparse(url_or_path_1)[0].lower()
    is_local = protocol == 'file'

    # Ignore case if dealing with a local file in a Windows machine
    if is_local:
        is_windows = Platform.GetCurrentFlavour() == 'windows'
        if is_windows:
            return url_or_path_1.lower() == url_or_path_2.lower()

    # All other cases are case sensitive
    return url_or_path_1 == url_or_path_2
예제 #2
0
    def testPlatform(self):
        p = Platform('win', '32')
        assert p.name == 'win'
        assert p.bits == '32'
        assert p.debug == False
        assert str(p) == 'win32'
        assert p.AsString(False) == 'win32'
        assert p.AsString(True) == 'win32'
        assert p.GetSimplePlatform() == 'i686.win32'
        assert p.GetBaseName() == 'win32'
        assert p.GetLongName() == 'Windows 32-bit'
        assert p.GetPlatformFlavour() == 'windows'
        assert p.GetMneumonic() == 'w32'

        p = Platform('win', '64', True)
        assert p.name == 'win'
        assert p.bits == '64'
        assert p.debug == True
        assert str(p) == 'win64d'
        assert p.AsString(False) == 'win64d'
        assert p.AsString(True) == 'win64'
        assert p.GetSimplePlatform() == 'amd64.win32'
        assert p.GetBaseName() == 'win64'
        assert p.GetLongName() == 'Windows 64-bit DEBUG'
        assert p.GetPlatformFlavour() == 'windows'
        assert p.GetMneumonic() == 'w64'

        with pytest.raises(ValueError):
            p = Platform('INVALID', '32')

        with pytest.raises(ValueError):
            p = Platform('win', 'INVALID')

        p = Platform('win', '32')
        p.name = 'INVALID'
        with pytest.raises(UnknownPlatform):
            p.GetSimplePlatform()

        with pytest.raises(UnknownPlatform):
            p.GetPlatformFlavour()

        with pytest.raises(UnknownPlatform):
            p.GetLongName()

        assert p.GetCurrentFlavour() == p.GetCurrentPlatform().GetPlatformFlavour()