~configglue/configglue/trunk

« back to all changes in this revision

Viewing changes to configglue/tests/inischema/test_glue.py

  • Committer: Tarmac
  • Author(s): John Zhuge
  • Date: 2016-10-31 13:29:42 UTC
  • mfrom: (117.1.1 short_name)
  • Revision ID: tarmac-20161031132942-lg5z6bnmn3iv2j96
[r=ricardokirkner] Support short_name attribute in config ini file for inischema.

Show diffs side-by-side

added added

removed removed

Lines of Context:
123
123
        self.assertEqual(options.x_a, '1')
124
124
 
125
125
 
 
126
class TestGlueShortName(TestBase):
 
127
    ini = b'[x]\nlong_opt.short_name=L'
 
128
 
 
129
    def test_accepts_long_args(self):
 
130
        parser, options, args = configglue(self.file, 'dummy',
 
131
                                           args=['', '--x_long_opt=13579'])
 
132
        self.assertEqual(options.x_long_opt, '13579')
 
133
 
 
134
    def test_accepts_short_args(self):
 
135
        parser, options, args = configglue(self.file, 'dummy',
 
136
                                           args=['', '-L86420'])
 
137
        self.assertEqual(options.x_long_opt, '86420')
 
138
 
 
139
    def test_help_displays_both_args(self):
 
140
        new_callable = StringIO
 
141
        if PY2:
 
142
            new_callable = BytesIO
 
143
 
 
144
        with patch('sys.stdout', new_callable=new_callable) as mock_stdout:
 
145
            try:
 
146
                configglue(self.file, args=['', '--help'])
 
147
            except SystemExit:
 
148
                output = mock_stdout.getvalue()
 
149
        self.assertTrue('-L X_LONG_OPT, --x_long_opt=X_LONG_OPT' in output)
 
150
 
 
151
 
126
152
class TestGlueBool(TestBase):
127
153
    ini = b'''[__main__]
128
154
foo.parser=bool