Example #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'
Example #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'
Example #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'
Example #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'
Example #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'
Example #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'
Example #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'
Example #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'
Example #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'
Example #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'