Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test_getters_dir test for windows, add missing long for py2, test… #4

Merged
merged 1 commit into from
Sep 23, 2016

Conversation

Hellowlol
Copy link
Contributor

…_create still fails because length is 5 on my computer and 4 in the data. Dunno whats correct

@coveralls
Copy link

Coverage Status

Coverage decreased (-2.0%) to 96.333% when pulling 579826c on Hellowlol:stuff into 5d68000 on idlesign:master.

# os.path.getsize() can be longs on py2
if sys.version_info <= (3, 0):
a_long = 741634835L
encoded_long = Bencode.encode(a_long)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual testing clause missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this simply proves that it works. Without adding long to int_types in the bencode file this would have failed.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Here we should use @pytest.mark.skipif so to check python version, otherwise we get SyntaxError on Py3. https://travis-ci.org/idlesign/torrentool/jobs/157047830#L260

@idlesign
Copy link
Owner

idlesign commented Sep 3, 2016

Thank you. There are questions though.

[...] _create still fails [...]

So total_size is not 23 I expect? Maybe a carriage-return related issue?

@Hellowlol
Copy link
Contributor Author

No, the length is 5. Ill add the traceback later. I cant remember what was wrong

@idlesign
Copy link
Owner

idlesign commented Sep 4, 2016

Ill add the traceback later.

OK, will wait.

@Hellowlol
Copy link
Contributor Author

Hellowlol commented Sep 4, 2016

============================= test session starts =============================
platform win32 -- Python 2.7.10, pytest-2.9.2, py-1.4.31, pluggy-0.3.1 -- C:\Python27\python.exe
cachedir: .cache
rootdir: C:\Users\steffen\Documents\GitHub\torrentool, inifile: 
plugins: cov-2.2.1, mock-1.1, xdist-1.14
collecting ... collected 16 items

tests/test_bencode.py::test_read_file_dir PASSED
tests/test_bencode.py::test_read_file PASSED
tests/test_bencode.py::test_decode_simple PASSED
tests/test_bencode.py::test_decode_errors PASSED
tests/test_bencode.py::test_encode_simple PASSED
tests/test_bencode.py::test_encode_complex PASSED
tests/test_bencode.py::test_encode_errors PASSED
tests/test_bencode.py::test_encode_error_long PASSED
tests/test_etc.py::test_get_app_version PASSED
tests/test_torrent.py::test_create FAILED
tests/test_torrent.py::test_getters_simple PASSED
tests/test_torrent.py::test_getters_dir PASSED
tests/test_torrent.py::test_setters PASSED
tests/test_torrent.py::test_from_string PASSED
tests/test_torrent.py::test_to_file PASSED
tests/test_torrent.py::test_str PASSED

================================== FAILURES ===================================
_________________________________ test_create _________________________________

    def test_create():
        fp = join(CURRENT_DIR, 'torrtest', 'root.txt')
        t = Torrent.create_from(fp)
        t.private = True

>       assert t._struct['info'] == STRUCT_TORRENT_SIMPLE['info']
E       assert {'length': 5L..."M7\xc3', ...} == OrderedDict([(...private', 1)])
E         Common items:
E         {'name': 'root.txt', 'piece length': 32768, 'private': 1}
E         Differing items:
E         {'length': 5L} != {'length': 4}
E         {'pieces': '\x02P\xa7\xb0\x95\xbcj\x96\x9a\xdb\xe2]\xe1M#\xc4"M7\xc3'} != {'pieces': '\xa8\xfd\xc2\x05\xa9\xf1\x9c\xc1\xc7Pz`\xc4\xf0\x1b\x13\xd1\x1d\x7f\xd0'}
E         Full diff:
E         + OrderedDict([('length', 4), ('name', 'root.txt'), ('piece length', 32768), ('pieces', '\xa8\xfd\xc2\x05\xa9\xf1\x9c\xc1\xc7Pz`\xc4\xf0\x1b\x13\xd1\x1d\x7f\xd0'), ('private', 1)])
E         - {'length': 5L,
E         -  'name': 'root.txt',
E         -  'piece length': 32768,
E         -  'pieces': '\x02P\xa7\xb0\x95\xbcj\x96\x9a\xdb\xe2]\xe1M#\xc4"M7\xc3',
E         -  'private': 1}

tests\test_torrent.py:20: AssertionError
===================== 1 failed, 15 passed in 0.11 seconds =====================

…_create still fails because length is 5 on my computer and 4 in the data. Dunno whats correct :P
@coveralls
Copy link

coveralls commented Sep 4, 2016

Coverage Status

Coverage increased (+0.01%) to 98.333% when pulling d65b77e on Hellowlol:stuff into 5d68000 on idlesign:master.

@Hellowlol
Copy link
Contributor Author

============================= test session starts =============================
platform win32 -- Python 3.5.1, pytest-2.9.2, py-1.4.31, pluggy-0.3.1 -- C:\Users\steffen\AppData\Local\Programs\Python\Python35\python.exe
cachedir: .cache
rootdir: C:\Users\steffen\Documents\GitHub\torrentool, inifile: 
plugins: cov-2.2.1, mock-1.1, xdist-1.14
collecting ... collected 16 items

tests/test_bencode.py::test_read_file_dir PASSED
tests/test_bencode.py::test_read_file PASSED
tests/test_bencode.py::test_decode_simple PASSED
tests/test_bencode.py::test_decode_errors PASSED
tests/test_bencode.py::test_encode_simple PASSED
tests/test_bencode.py::test_encode_complex PASSED
tests/test_bencode.py::test_encode_errors PASSED
tests/test_bencode.py::test_encode_error_long xfail
tests/test_etc.py::test_get_app_version PASSED
tests/test_torrent.py::test_create FAILED
tests/test_torrent.py::test_getters_simple PASSED
tests/test_torrent.py::test_getters_dir PASSED
tests/test_torrent.py::test_setters PASSED
tests/test_torrent.py::test_from_string PASSED
tests/test_torrent.py::test_to_file PASSED
tests/test_torrent.py::test_str PASSED

================================== FAILURES ===================================
_________________________________ test_create _________________________________

    def test_create():
        fp = join(CURRENT_DIR, 'torrtest', 'root.txt')
        t = Torrent.create_from(fp)
        t.private = True

>       assert t._struct['info'] == STRUCT_TORRENT_SIMPLE['info']
E       assert {'length': 5,..."M7\xc3', ...} == OrderedDict([(...private', 1)])
E         Common items:
E         {'name': 'root.txt', 'piece length': 32768, 'private': 1}
E         Differing items:
E         {'pieces': b'\x02P\xa7\xb0\x95\xbcj\x96\x9a\xdb\xe2]\xe1M#\xc4"M7\xc3'} != {'pieces': b'\xa8\xfd\xc2\x05\xa9\xf1\x9c\xc1\xc7Pz`\xc4\xf0\x1b\x13\xd1\x1d\x7f\xd0'}
E         {'length': 5} != {'length': 4}
E         Full diff:
E         - {'length': 5,
E         -  'name': 'root.txt',
E         -  'piece length': 32768,
E         -  'pieces': b'\x02P\xa7\xb0\x95\xbcj\x96\x9a\xdb\xe2]\xe1M#\xc4"M7\xc3',
E         -  'private': 1}
E         + OrderedDict([('length', 4),
E         +              ('name', 'root.txt'),
E         +              ('piece length', 32768),
E         +              ('pieces',
E         +               b'\xa8\xfd\xc2\x05\xa9\xf1\x9c\xc1\xc7Pz`\xc4\xf0\x1b\x13'
E         +               b'\xd1\x1d\x7f\xd0'),
E         +              ('private', 1)])

tests\test_torrent.py:20: AssertionError
=============== 1 failed, 14 passed, 1 xfailed in 0.25 seconds ================

@idlesign
Copy link
Owner

idlesign commented Sep 5, 2016

Since there are 4 bytes 31 32 33 0A originally, I suppose that is indeed a carriage return issue.
That maybe related to you Git core.autocrlf setting.

We can .gitattributes file with to have the same test results on both systems.

tests/torrtest/*.txt text eol=lf

idlesign added a commit that referenced this pull request Sep 23, 2016
@idlesign idlesign merged commit 71747fb into idlesign:master Sep 23, 2016
@idlesign
Copy link
Owner

Merged.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants