예제 #1
0
def test_preferred_encodings():
    cache = Cache(suffix='-pytest')
    cache.clear()
    encodings = cache.preferred_encodings
    assert len(encodings) == 1
    assert encodings[0] == convert_to_codec_key(locale.getpreferredencoding())
    encodings.append('utf_16')
    cache.preferred_encodings = encodings
    cache2 = Cache(suffix='-pytest')
    assert 'utf_16' in cache2.preferred_encodings
예제 #2
0
def test_preferred_encodings():
    cache = Cache(suffix='-pytest')
    cache.clear()
    encodings = cache.preferred_encodings
    assert len(encodings) == 1
    assert encodings[0] == convert_to_codec_key(
        locale.getpreferredencoding())
    encodings.append('utf_16')
    cache.preferred_encodings = encodings
    cache2 = Cache(suffix='-pytest')
    assert 'utf_16' in cache2.preferred_encodings
    def edit_encoding(cls, parent):
        """
        Static helper method that shows the encoding editor dialog
        If the dialog was accepted the new encodings are added to the settings.

        :param parent: parent widget
        :return: True in case of succes, False otherwise

        """
        dlg = cls(parent)
        if dlg.exec_() == dlg.Accepted:
            settings = Cache()
            settings.preferred_encodings = dlg.get_preferred_encodings()
            return True
        return False
예제 #4
0
    def edit_encoding(cls, parent):
        """
        Static helper method that shows the encoding editor dialog
        If the dialog was accepted the new encodings are added to the settings.

        :param parent: parent widget
        :return: True in case of succes, False otherwise

        """
        dlg = cls(parent)
        if dlg.exec_() == dlg.Accepted:
            settings = Cache()
            settings.preferred_encodings = dlg.get_preferred_encodings()
            return True
        return False