Exemplo n.º 1
0
def test_comments():
    c = read_config(StringIO('''
# This is a comment
--gettext xyz
   # This is a comment with whitespace upfront
'''))
    assert c.gettext_dir == 'xyz'
Exemplo n.º 2
0
def test_comments():
    c = read_config(
        StringIO('''
# This is a comment
--gettext xyz
   # This is a comment with whitespace upfront
'''))
    assert c.gettext_dir == 'xyz'
Exemplo n.º 3
0
def test_path_rebase():
    """Paths in the config file are made relative to their location.
    """
    file = StringIO('''--gettext ../gettext\n--android ../res''')
    file.name = '/opt/proj/android/shared/.config'
    c = read_config(file)
    print c.gettext_dir
    assert c.gettext_dir == '/opt/proj/android/gettext'
    assert c.resource_dir == '/opt/proj/android/res'
Exemplo n.º 4
0
def test_path_rebase():
    """Paths in the config file are made relative to their location.
    """
    file = StringIO('''--gettext ../gettext\n--android ../res''')
    file.name = '/opt/proj/android/shared/.config'
    c = read_config(file)
    print c.gettext_dir
    assert c.gettext_dir == '/opt/proj/android/gettext'
    assert c.resource_dir == '/opt/proj/android/res'
Exemplo n.º 5
0
def test_path_rebase():
    """Paths in the config file are made relative to their location.
    """
    # In Python 2.6, you can't set StringIO object's name attribute, so this
    # allows us to mock an opened file in 2.6+.
    class MockFile(StringIO):
        name = None
        def __init__(self, name, buffer_=None):
            super(MockFile, self).__init__(buffer_)
            self.name = name
    file = MockFile('/opt/proj/android/shared/.config', '''--gettext ../gettext\n--android ../res''')
    c = read_config(file)
    print(c.gettext_dir)
    assert c.gettext_dir == '/opt/proj/android/gettext'
    assert c.resource_dir == '/opt/proj/android/res'
Exemplo n.º 6
0
def test_path_rebase():
    """Paths in the config file are made relative to their location.
    """

    # In Python 2.6, you can't set StringIO object's name attribute, so this
    # allows us to mock an opened file in 2.6+.
    class MockFile(StringIO):
        name = None

        def __init__(self, name, buffer_=None):
            super(MockFile, self).__init__(buffer_)
            self.name = name

    file = MockFile('/opt/proj/android/shared/.config',
                    '''--gettext ../gettext\n--android ../res''')
    c = read_config(file)
    print(c.gettext_dir)
    assert c.gettext_dir == '/opt/proj/android/gettext'
    assert c.resource_dir == '/opt/proj/android/res'
Exemplo n.º 7
0
def test_valid_args():
    c = read_config(StringIO('--gettext xyz\n--android foo'))
    assert c.gettext_dir == 'xyz'
    assert c.resource_dir == 'foo'
Exemplo n.º 8
0
def test_whitespace():
    """Whitespace in front of lines or at the end is ignored.
    """
    c = read_config(StringIO('''   --gettext xyz  '''))
    assert c.gettext_dir == 'xyz'
Exemplo n.º 9
0
def test_whitespace():
    """Whitespace in front of lines or at the end is ignored.
    """
    c = read_config(StringIO('''   --gettext xyz  '''))
    assert c.gettext_dir == 'xyz'
Exemplo n.º 10
0
def test_valid_args():
    c = read_config(StringIO('--gettext xyz\n--android foo'))
    assert c.gettext_dir == 'xyz'
    assert c.resource_dir == 'foo'