Skip to content

Commit

Permalink
fix test in byteMzml pull request
Browse files Browse the repository at this point in the history
  • Loading branch information
MKoesters committed Apr 1, 2019
1 parent 94f8385 commit 21b999a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
9 changes: 7 additions & 2 deletions pymzml/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,14 @@ def _determine_file_encoding(self, path):
Returns:
mzml_encoding (str): encoding type of the file
"""
mzml_encoding = 'utf-8'
if os.path.exists(path):
with open(path, 'rb') as sniffer:
print(path)
if path.endswith('.gz') or path.endswith('.igz'):
import gzip
_open = gzip.open
else:
_open = open
with _open(path, 'rb') as sniffer:
return self._guess_encoding(sniffer)

def _init_obo_translator(self):
Expand Down
26 changes: 13 additions & 13 deletions tests/main_reader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class runTest(unittest.TestCase):
def setUp(self):
"""
"""
paths = test_file_paths.paths
self.paths = test_file_paths.paths

file_compressed_indexed = paths[2]
file_compressed_unindexed = paths[1]
file_uncompressed_indexed = paths[0]
file_uncompressed_unindexed = paths[0]
file_compressed_indexed = self.paths[2]
file_compressed_unindexed = self.paths[1]
file_uncompressed_indexed = self.paths[0]
file_uncompressed_unindexed = self.paths[0]
self.reader_compressed_indexed = run.Reader(file_compressed_indexed)
self.reader_compressed_unindexed = run.Reader(file_compressed_unindexed)
self.reader_uncompressed_indexed = run.Reader(file_uncompressed_indexed)
Expand All @@ -30,14 +30,14 @@ def setUp(self):
def test_determine_file_encoding(self):
"""
"""
encoding = self.reader_compressed_indexed._determine_file_encoding(self.reader_compressed_indexed.info['encoding'])
self.assertEqual(encoding, 'utf-8')
encoding = self.reader_compressed_unindexed._determine_file_encoding(self.reader_compressed_unindexed.info['encoding'])
self.assertEqual(encoding, 'utf-8')
encoding = self.reader_uncompressed_indexed._determine_file_encoding(self.reader_uncompressed_indexed.info['encoding'])
self.assertEqual(encoding, 'utf-8')
encoding = self.reader_uncompressed_unindexed._determine_file_encoding(self.reader_uncompressed_unindexed.info['encoding'])
self.assertEqual(encoding, 'utf-8')
encoding = self.reader_compressed_indexed._determine_file_encoding(self.paths[2])
self.assertEqual(encoding, 'ISO-8859-1')
encoding = self.reader_compressed_unindexed._determine_file_encoding(self.paths[1])
self.assertEqual(encoding, 'ISO-8859-1')
encoding = self.reader_uncompressed_indexed._determine_file_encoding(self.paths[3])
self.assertEqual(encoding, 'ISO-8859-1')
encoding = self.reader_uncompressed_unindexed._determine_file_encoding(self.paths[0])
self.assertEqual(encoding, 'ISO-8859-1')

def test_init_iter(self):
"""
Expand Down

0 comments on commit 21b999a

Please sign in to comment.