Skip to content

Commit

Permalink
Modifying test_util to work in the windows environment (scikit-bio#2068)
Browse files Browse the repository at this point in the history
* modifying test_util to work on the windows environment

* fixing errors in test_registry.py
  • Loading branch information
RaeedA authored Jun 28, 2024
1 parent 094a82e commit c726170
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions skbio/io/tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1710,8 +1710,8 @@ def writer(obj, fh):
for line in iterator:
fh.write(line)

self.registry.write(obj, format='format1', into=fp, compression='bz2')
self.registry.write(obj, format='format1', into=f, compression='bz2')
self.registry.write(obj, format='format1', into=fp, compression='bz2', newline='\n')
self.registry.write(obj, format='format1', into=f, compression='bz2', newline='\n')
expected = (
b'BZh91AY&SY\x03\x89\x0c\xa6\x00\x00\x01\xc1\x00\x00\x108\x00 \x00'
b'!\x9ah3M\x1c\xb7\x8b\xb9"\x9c(H\x01\xc4\x86S\x00')
Expand Down
7 changes: 4 additions & 3 deletions skbio/io/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,12 @@ def check_closed(self, file, expected):

def check_open_state_contents(self, file, contents, is_binary,
**kwargs):
result = skbio.io.open(file, mode='w', **kwargs)
if is_binary:
result = skbio.io.open(file, mode='w', **kwargs)
self.assertIsInstance(result, (io.BufferedWriter,
io.BufferedRandom))
else:
result = skbio.io.open(file, mode='w', **kwargs, newline='')
self.assertIsInstance(result, io.TextIOBase)
self.assertTrue(result.writable())

Expand Down Expand Up @@ -396,11 +397,11 @@ def setUp(self):
self._dir = tempfile.mkdtemp()

with io.open(get_data_path('example_file'), mode='rb') as f:
self.binary_contents = f.read()
self.binary_contents = f.read().decode('utf8').replace("\r\n", "\n", -1).encode('utf8')
self.binary_file = self._make_file('example_file')

with io.open(get_data_path('big5_file'), mode='rb') as f:
self.encoded_contents = f.read()
self.encoded_contents = f.read().decode('big5').replace("\r\n", "\n", -1).encode('big5')
self.big5_file = self._make_file('big5_file')

with io.open(get_data_path('example_file.gz'), mode='rb') as f:
Expand Down

0 comments on commit c726170

Please sign in to comment.