def _do_test_flagfile(self, flags, conf):
        self.files['foo.flags'] = flags

        before = ['--flagfile=foo.flags']

        after = flagfile.handle_flagfiles(before, tempdir=self.tempdir)

        self.assertEquals(after,
                          ['--config-file=' + t
                           for t in reversed(self.tempfiles)])
        self.assertEquals(self.files[self.tempfiles[-1]],
                          '[DEFAULT]\n' + conf)
    def test_empty_flagfile_with_other_args(self):
        self.files['foo.flags'] = ''

        before = [
            '--foo', 'bar',
            '--flagfile=foo.flags',
            '--blaa=foo',
            '--foo-flagfile',
            '--flagfile-foo'
            ]

        after = flagfile.handle_flagfiles(before, tempdir=self.tempdir)

        self.assertEquals(after, [
                '--foo', 'bar',
                '--config-file=' + self.tempfiles[-1],
                '--blaa=foo',
                '--foo-flagfile',
                '--flagfile-foo'])
        self.assertEquals(self.files[self.tempfiles[-1]], '[DEFAULT]\n')
 def _do_test_empty_flagfile(self, before):
     self.files['foo.flags'] = ''
     after = flagfile.handle_flagfiles(before, tempdir=self.tempdir)
     self.assertEquals(after, ['--config-file=' + self.tempfiles[-1]])
     self.assertEquals(self.files[self.tempfiles[-1]], '[DEFAULT]\n')
 def test_no_args(self):
     before = []
     after = flagfile.handle_flagfiles(before, tempdir=self.tempdir)
     self.assertEquals(after, before)
 def test_flagfile_is_config(self):
     self.files['foo.flags'] = '\n\n#foo\n//bar\n[DEFAULT]\nbar=foo'
     before = ['--flagfile=foo.flags']
     after = flagfile.handle_flagfiles(before, tempdir=self.tempdir)
     self.assertEquals(after, ['--config-file=foo.flags'])