Closed
Description
Originally reported by: Floris Bruynooghe (BitBucket: flub, GitHub: flub)
When using unicode literals to add options in pytest_addoption argparse fails:
from __future__ import unicode_literals
def pytest_addoption(parser):
parser.addoption('--foo', action='store', type='string', help='do foo')
Results in:
$ py.test
Traceback (most recent call last):
File "/home/flub/.local/bin/py.test", line 9, in <module>
load_entry_point('pytest==2.4.0', 'console_scripts', 'py.test')()
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/config.py", line 18, in main
config = _prepareconfig(args, plugins)
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/config.py", line 63, in _prepareconfig
pluginmanager=pluginmanager, args=args)
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/core.py", line 364, in __call__
return self._docall(methods, kwargs)
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/core.py", line 375, in _docall
res = mc.execute()
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/core.py", line 293, in execute
res = method(**kwargs)
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/helpconfig.py", line 25, in pytest_cmdline_parse
config = __multicall__.execute()
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/core.py", line 293, in execute
res = method(**kwargs)
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/config.py", line 618, in pytest_cmdline_parse
self.parse(args)
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/config.py", line 715, in parse
args = self._parser.parse_setoption(args, self.option)
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/config.py", line 167, in parse_setoption
parsedoption = self.parse(args)
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/config.py", line 145, in parse
self.optparser = self._getparser()
File "/home/flub/.local/lib/python2.7/site-packages/_pytest/config.py", line 160, in _getparser
arggroup.add_argument(*n, **a)
File "/usr/lib/python2.7/argparse.py", line 1286, in add_argument
raise ValueError('%r is not callable' % (type_func,))
ValueError: u'string' is not callable