Comment 1 for bug 1378888

Revision history for this message
Tony Reix (tony-reix) wrote :

In Avro, the issue appears as:

  [py-test] ERROR: test_fields (test_script.TestCat)
  [py-test] ----------------------------------------------------------------------
  [py-test] Traceback (most recent call last):
  [py-test] File "/home/tony/AVRO/avro-FromFreshIBMSOEGitHub/lang/py/build/test/test_script.py", line 169, in test_fields
  [py-test] out = self._run('--fields', 'first, last')
  [py-test] File "/home/tony/AVRO/avro-FromFreshIBMSOEGitHub/lang/py/build/test/test_script.py", line 109, in _run
  [py-test] out = check_output([SCRIPT, "cat", self.avro_file] + list(args))
  [py-test] File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
  [py-test] raise CalledProcessError(retcode, cmd, output=output)
  [py-test] CalledProcessError: Command '['/home/tony/AVRO/avro-FromFreshIBMSOEGitHub/lang/py/build/test/../scripts/avro', 'cat', '/tmp/tmp3Oiy6H', '--fields', 'first, last']' returned non-zero exit status 2

If the string 'first, last' is replaced by 'first,last' (no space), another issue appears (that does not appear on x86_64), with the string '' :

  [py-test] ERROR: test_fields (test_script.TestCat)
  [py-test] Traceback (most recent call last):
  [py-test]
  [py-test] File "/home/tony/AVRO/avro-FromFreshIBMSOEGitHub/lang/py/build/test/test_script.py", line 173, in test_fields
  [py-test] Schema: ["string", "null", "long"]
  [py-test] out = self._run('--fields', '')
  [py-test] Datum: None
  [py-test] File "/home/tony/AVRO/avro-FromFreshIBMSOEGitHub/lang/py/build/test/test_script.py", line 109, in _run
  [py-test] Codec: deflate
  [py-test] out = check_output([SCRIPT, "cat", self.avro_file] + list(args))
  [py-test] Round Trip Data: [None, None, None, None, None, None, None, None, None, None]
  [py-test] File "/usr/lib/python2.7/subprocess.py", line 573, in check_output
  [py-test] Round Trip Data Length: 10
  [py-test] raise CalledProcessError(retcode, cmd, output=output)
  [py-test] Correct Round Trip: True
  [py-test]
  [py-test] CalledProcessError: Command '['/home/tony/AVRO/avro-FromFreshIBMSOEGitHub/lang/py/build/test/../scripts/avro', 'cat', '/tmp/tmpJJp2gX', '--fields', '']' returned non-zero exit status 2

The issue in Python is triggered by this Avro test file:
    lang/py/build/test/test_script.py

class TestCat(unittest.TestCase):
.....
     def test_fields(self):
     ...
        # Field selection (with comma and space)
        out = self._run('--fields', 'first, last')
        assert json.loads(out[0]) == {'first': 'daffy', 'last': 'duck'}

        # Empty fields should get all
        out = self._run('--fields', '')

So, there are 2 issues with OptionParser():
 - 'first, last'
 - '' (empty field)