From f97fc38932e4396435cb13c54ca2ad12ac4d7b8b Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 21 Aug 2017 11:12:19 +0200 Subject: [PATCH 1/2] test: clarify test_fileish_types There was a naming problem on case-insensitive filesystems, which is why the tests refered to both 'Settings.FIT' and 'Settings.FIT', with the latter not inside git, and tests failing on all case-sensitive filesystems. Fix this by duplicating 'Settings.fit' to 'nametest.FIT', and using it inside `test_fileish_types(self)`. Also improve test documentation a bit, while adding a link to the underlying issue. --- tests/files/nametest.FIT | Bin 0 -> 1287 bytes tests/test.py | 14 +++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 tests/files/nametest.FIT diff --git a/tests/files/nametest.FIT b/tests/files/nametest.FIT new file mode 100644 index 0000000000000000000000000000000000000000..13cd3334c8a33d6426f72d227db8ab4cfe77d676 GIT binary patch literal 1287 zcma)+yNeT16vn^r%$+=LvPm}CM^uCbSL0?yb{FFVETRxaSaorOh>e8?Sp-W98!d)3 z<9{GnTiQu1M6mTw*xt%cuuD95HW_Ef6!R7Hxc8jjdE7^(w&edYz{Oj4`al<|oM+w{ zGo%C}fiD3F{AwTmoT!KsxyeM-ZW{s#NI{?wv;JKljWjYp3S1oqW~_V(wQP@8=O2Bii=D%|#`esxW$Z@T zs*#bb}L9PN49 zP1*~ZQ19V=RKEeAaHvTD!H1EwI>733qrO-P_sUb;e1hfsv;gY`=8C$8&+NzD|L=H}2iu@An>HnqlKd9ciF0VWg*R2YhlI z=yp~z!@DTHO_uCDJFVj-dl3#ec%1=w^Weo`O?#G9Iz!$3Q~eKw+jy$DhY|4d(ctWv z2KuuJWCdP{J)(~^Fc(i}1zwFk<^uEabXMTC*kdkGmv*YGz{ELpp6QZ{GhT)sc7Zo2 hdd<9Ur|8;=Zv+$xy@JrwlfRZc`ZKz_(p2v^{{jjSp?&}W literal 0 HcmV?d00001 diff --git a/tests/test.py b/tests/test.py index 8d36db7..d592cbe 100755 --- a/tests/test.py +++ b/tests/test.py @@ -399,14 +399,18 @@ def test_int_long(self): assert f.messages[-1].fields[1].raw_value == 1739.486328125 def test_fileish_types(self): - """Test the constructor does the right thing when given different types""" - with FitFile(testfile('Settings.FIT')): + """Test the constructor does the right thing when given different types + (specifically, test files with 8 characters, followed by an uppercase.FIT + extension), which confused the fileish check on Python 2, see + https://github.com/dtcooper/python-fitparse/issues/29#issuecomment-312436350 + for details""" + with FitFile(testfile('nametest.FIT')): pass - with FitFile(open(testfile("Settings.fit"), 'rb')): + with FitFile(open(testfile("nametest.FIT"), 'rb')): pass - with FitFile(open(testfile("Settings.fit"), 'rb').read()): + with FitFile(open(testfile("nametest.FIT"), 'rb').read()): pass - with FitFile(io.BytesIO(open(testfile("Settings.fit"), 'rb').read())): + with FitFile(io.BytesIO(open(testfile("nametest.FIT"), 'rb').read())): pass def test_elemnt_bolt_developer_data_id_without_application_id(self): From 1636660672de4532c5b8820b4dc00da681e043f4 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Mon, 21 Aug 2017 11:21:40 +0200 Subject: [PATCH 2/2] =?UTF-8?q?test:=20fix=20ResourceWarning:=20unclosed?= =?UTF-8?q?=20file=20=E2=80=A6=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test.py b/tests/test.py index d592cbe..2b97af8 100755 --- a/tests/test.py +++ b/tests/test.py @@ -406,12 +406,12 @@ def test_fileish_types(self): for details""" with FitFile(testfile('nametest.FIT')): pass - with FitFile(open(testfile("nametest.FIT"), 'rb')): - pass - with FitFile(open(testfile("nametest.FIT"), 'rb').read()): - pass - with FitFile(io.BytesIO(open(testfile("nametest.FIT"), 'rb').read())): - pass + with open(testfile("nametest.FIT"), 'rb') as f: + FitFile(f) + with open(testfile("nametest.FIT"), 'rb') as f: + FitFile(f.read()) + with open(testfile("nametest.FIT"), 'rb') as f: + FitFile(io.BytesIO(f.read())) def test_elemnt_bolt_developer_data_id_without_application_id(self): """Test that a file without application id set inside developer_data_id is parsed