isislovecruft / python-gnupg

A modified version of python-gnupg, including security patches, extensive documentation, and extra features.
Other
424 stars 172 forks source link

py3k unittest failures #16

Closed isislovecruft closed 10 years ago

isislovecruft commented 11 years ago

most of these are due to trivialities, such as Exception objects no longer having a message attribute, and bytestrings being returned and then compared to string literals. should be easy to fix.

======================================================================
ERROR: test_make_args (__main__.GPGTestCase)
Test argument line construction.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 200, in _is_allowed
    assert hyphenated in allowed
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 290, in _check_option
    flag = _is_allowed(arg)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 204, in _is_allowed
    raise ProtectedOption("Option '%s' not supported." % dropped)
gnupg._parsers.ProtectedOption: Option '--bicycle' not supported.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./gnupg/test/test_gnupg.py", line 334, in test_make_args
    args = self.gpg._make_args(not_allowed[2:], False)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_meta.py", line 441, in _make_args
    [cmd.append(opt) for opt in iter(_sanitise_list(self.options))]
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_meta.py", line 441, in <listcomp>
    [cmd.append(opt) for opt in iter(_sanitise_list(self.options))]
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 441, in _sanitise_list
    safe_arg = _sanitise(arg)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 423, in _sanitise
    checked = _check_groups(option_groups)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 395, in _check_groups
    safe = _check_option(a, v)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 293, in _check_option
    log.warn("_check_option(): %s" % error.message)
AttributeError: 'ProtectedOption' object has no attribute 'message'

======================================================================
ERROR: test_make_args_drop_protected_options (__main__.GPGTestCase)
Test that unsupported gpg options are dropped.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 200, in _is_allowed
    assert hyphenated in allowed
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 290, in _check_option
    flag = _is_allowed(arg)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 204, in _is_allowed
    raise ProtectedOption("Option '%s' not supported." % dropped)
gnupg._parsers.ProtectedOption: Option '--tyrannosaurus-rex' not supported.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./gnupg/test/test_gnupg.py", line 321, in test_make_args_drop_protected_options
    cmd = self.gpg._make_args(None, False)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_meta.py", line 441, in _make_args
    [cmd.append(opt) for opt in iter(_sanitise_list(self.options))]
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_meta.py", line 441, in <listcomp>
    [cmd.append(opt) for opt in iter(_sanitise_list(self.options))]
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 441, in _sanitise_list
    safe_arg = _sanitise(arg)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 423, in _sanitise
    checked = _check_groups(option_groups)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 395, in _check_groups
    safe = _check_option(a, v)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_parsers.py", line 293, in _check_option
    log.warn("_check_option(): %s" % error.message)
AttributeError: 'ProtectedOption' object has no attribute 'message'

======================================================================
ERROR: test_copy_data_bytesio (__main__.GPGTestCase)
Test that _copy_data() is able to duplicate byte streams.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./gnupg/test/test_gnupg.py", line 356, in test_copy_data_bytesio
    instream = io.BytesIO(message)
TypeError: 'str' does not support the buffer interface

======================================================================
ERROR: test_parsers_fix_unsafe (__main__.GPGTestCase)
Test that unsafe inputs are quoted out and then ignored.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_util.py", line 274, in _is_file
    assert os.lstat(input).st_size > 0, "not a file: %s" % input
FileNotFoundError: [Errno 2] No such file or directory: '\'"&coproc /bin/sh"\''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./gnupg/test/test_gnupg.py", line 223, in test_parsers_fix_unsafe
    has_shell = self.gpg.verify_file(test_file, fixed)
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/gnupg.py", line 245, in verify_file
    if not _util._is_file(sig_file):
  File "/home/isis/.virtualenvs/py3kgnupg/lib/python3.3/site-packages/gnupg-1.2.1_15_g08f066d_dirty-py3.3.egg/gnupg/_util.py", line 276, in _is_file
    log.error(err.message, exc_info=1)
AttributeError: 'FileNotFoundError' object has no attribute 'message'

======================================================================
ERROR: test_signature_verification_detached_binary (__main__.GPGTestCase)
Test that detached signature verification in binary mode fails.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./gnupg/test/test_gnupg.py", line 720, in test_signature_verification_detached_binary
    bs.write(sig.data)
TypeError: must be str, not bytes

======================================================================
ERROR: test_signature_verification_detached (__main__.GPGTestCase)
Test that verification of a detached signature of a file works.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./gnupg/test/test_gnupg.py", line 697, in test_signature_verification_detached
    sigfile.write(sig.data)
TypeError: must be str, not bytes

======================================================================
ERROR: test_file_encryption_and_decryption (__main__.GPGTestCase)
Test that encryption/decryption to/from file works.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./gnupg/test/test_gnupg.py", line 965, in test_file_encryption_and_decryption
    data = data.encode(self.gpg._encoding)
AttributeError: 'bytes' object has no attribute 'encode'

======================================================================
FAIL: test_encryption_decryption_multi_recipient (__main__.GPGTestCase)
Test decryption of an encrypted string for multiple users
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./gnupg/test/test_gnupg.py", line 919, in test_encryption_decryption_multi_recipient
    self.assertEquals(message, str(dec_alice.data))
AssertionError: '\nIn 2010 Riggio and Sicari presented a practical application of homomorphic\ne [truncated]... != "b''"
+ b''-
- In 2010 Riggio and Sicari presented a practical application of homomorphic
- encryption to a hybrid wireless sensor/mesh network. The system enables
- transparent multi-hop wireless backhauls that are able to perform statistical
- analysis of different kinds of data (temperature, humidity, etc.)  coming from
- a WSN while ensuring both end-to-end encryption and hop-by-hop
- authentication.

======================================================================
FAIL: test_symmetric_encryption_and_decryption (__main__.GPGTestCase)
Test symmetric encryption and decryption
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./gnupg/test/test_gnupg.py", line 941, in test_symmetric_encryption_and_decryption
    self.assertEqual(decrypted, msg)
AssertionError: 'b"If you have something that you don\'t want anyone to\\nknow, maybe you should [truncated]... != "If you have something that you don't want anyone to\nknow, maybe you shouldn't  [truncated]...
- b"If you have something that you don't want anyone to\nknow, maybe you shouldn't be doing it in the first place.\n-- Eric Schmidt, CEO of Google"
? --                                                   ^^                                                         ^^                              -
+ If you have something that you don't want anyone to
know, maybe you shouldn't be doing it in the first place.
-- Eric Schmidt, CEO of Google
?                                                    ^                                                         ^

----------------------------------------------------------------------
Ran 51 tests in 26.577s

FAILED (failures=2, errors=7)
make: *** [test] Error 1
(py3kgnupg)∃!isisⒶwintermute:(develop *>)~/code/riseup/python-gnupg ∴
mattieb commented 10 years ago

I've been hard at work on these. Of note:

I'm currently stuck here though:

======================================================================
ERROR: test_file_encryption_and_decryption (__main__.GPGTestCase)
Test that encryption/decryption to/from file works.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./gnupg/test/test_gnupg.py", line 984, in test_file_encryption_and_decryption
    data = data.encode(self.gpg._encoding)
AttributeError: 'bytes' object has no attribute 'encode'

which is driving me batty because I don't get why data is a bytes. It was read in text mode from msg, it should be a str… shouldn't it?

isislovecruft commented 10 years ago

Issue #43 was fixed by @zigg, so this issue should have been fixed in version 1.2.6. Thanks again, @zigg!