Beispiel #1
0
def test_protect_filename():
    pairs = [ ('abc','abc'),
              (' abc',r'\ abc'),
              ('a bc',r'a\ bc'),
              ('a  bc',r'a\ \ bc'),
              ('  bc',r'\ \ bc'),
              ]
    # On posix, we also protect parens and other special characters
    if sys.platform != 'win32':
        pairs.extend( [('a(bc',r'a\(bc'),
                       ('a)bc',r'a\)bc'),
                       ('a( )bc',r'a\(\ \)bc'),
                       ('a[1]bc', r'a\[1\]bc'),
                       ('a{1}bc', r'a\{1\}bc'),
                       ('a#bc', r'a\#bc'),
                       ('a?bc', r'a\?bc'),
                       ('a=bc', r'a\=bc'),
                       ('a\\bc', r'a\\bc'),
                       ('a|bc', r'a\|bc'),
                       ('a;bc', r'a\;bc'),
                       ('a:bc', r'a\:bc'),
                       ("a'bc", r"a\'bc"),
                       ('a*bc', r'a\*bc'),
                       ('a"bc', r'a\"bc'),
                       ('a^bc', r'a\^bc'),
                       ('a&bc', r'a\&bc'),
                       ] )
    # run the actual tests
    for s1, s2 in pairs:
        s1p = completer.protect_filename(s1)
        nt.assert_equal(s1p, s2)
def test_protect_filename():
    pairs = [
        ('abc', 'abc'),
        (' abc', r'\ abc'),
        ('a bc', r'a\ bc'),
        ('a  bc', r'a\ \ bc'),
        ('  bc', r'\ \ bc'),
    ]
    # On posix, we also protect parens and other special characters
    if sys.platform != 'win32':
        pairs.extend([
            ('a(bc', r'a\(bc'),
            ('a)bc', r'a\)bc'),
            ('a( )bc', r'a\(\ \)bc'),
            ('a[1]bc', r'a\[1\]bc'),
            ('a{1}bc', r'a\{1\}bc'),
            ('a#bc', r'a\#bc'),
            ('a?bc', r'a\?bc'),
            ('a=bc', r'a\=bc'),
            ('a\\bc', r'a\\bc'),
            ('a|bc', r'a\|bc'),
            ('a;bc', r'a\;bc'),
            ('a:bc', r'a\:bc'),
            ("a'bc", r"a\'bc"),
            ('a*bc', r'a\*bc'),
            ('a"bc', r'a\"bc'),
            ('a^bc', r'a\^bc'),
            ('a&bc', r'a\&bc'),
        ])
    # run the actual tests
    for s1, s2 in pairs:
        s1p = completer.protect_filename(s1)
        nt.assert_equal(s1p, s2)
Beispiel #3
0
def test_protect_filename():
    pairs = [ ('abc','abc'),
              (' abc',r'\ abc'),
              ('a bc',r'a\ bc'),
              ('a  bc',r'a\ \ bc'),
              ('  bc',r'\ \ bc'),
              ]
    # On posix, we also protect parens
    if sys.platform != 'win32':
        pairs.extend( [('a(bc',r'a\(bc'),
                       ('a)bc',r'a\)bc'),
                       ('a( )bc',r'a\(\ \)bc'),
                       ] )
    # run the actual tests
    for s1, s2 in pairs:
        s1p = completer.protect_filename(s1)
        nt.assert_equals(s1p, s2)
Beispiel #4
0
def test_protect_filename():
    if sys.platform == "win32":
        pairs = [
            ("abc", "abc"),
            (" abc", '" abc"'),
            ("a bc", '"a bc"'),
            ("a  bc", '"a  bc"'),
            ("  bc", '"  bc"'),
        ]
    else:
        pairs = [
            ("abc", "abc"),
            (" abc", r"\ abc"),
            ("a bc", r"a\ bc"),
            ("a  bc", r"a\ \ bc"),
            ("  bc", r"\ \ bc"),
            # On posix, we also protect parens and other special characters.
            ("a(bc", r"a\(bc"),
            ("a)bc", r"a\)bc"),
            ("a( )bc", r"a\(\ \)bc"),
            ("a[1]bc", r"a\[1\]bc"),
            ("a{1}bc", r"a\{1\}bc"),
            ("a#bc", r"a\#bc"),
            ("a?bc", r"a\?bc"),
            ("a=bc", r"a\=bc"),
            ("a\\bc", r"a\\bc"),
            ("a|bc", r"a\|bc"),
            ("a;bc", r"a\;bc"),
            ("a:bc", r"a\:bc"),
            ("a'bc", r"a\'bc"),
            ("a*bc", r"a\*bc"),
            ('a"bc', r"a\"bc"),
            ("a^bc", r"a\^bc"),
            ("a&bc", r"a\&bc"),
        ]
    # run the actual tests
    for s1, s2 in pairs:
        s1p = completer.protect_filename(s1)
        assert s1p == s2