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

Issue with byte array caused by Python version 3.8.5 #155

Open
deng113jie opened this issue Apr 19, 2021 · 1 comment
Open

Issue with byte array caused by Python version 3.8.5 #155

deng113jie opened this issue Apr 19, 2021 · 1 comment

Comments

@deng113jie
Copy link
Contributor

No description provided.

@deng113jie
Copy link
Contributor Author

Unittest report error when running test_session with python version 3.8.5:

FAIL: test_create_then_load_categorical (tests.test_session.TestCreateThenLoadBetweenSessionsNew)

Traceback (most recent call last):
File "/home/jie/ExeTera/tests/test_session.py", line 103, in test_create_then_load_categorical
self.assertDictEqual({1: b'a', 2: b'b'}, f.keys)
AssertionError: {1: b'a', 2: b'b'} != {1: 'a', 2: 'b'}

  • {1: b'a', 2: b'b'}
    ? - -
  • {1: 'a', 2: 'b'}

======================================================================
FAIL: test_create_then_load_categorical (tests.test_session.TestCreateThenLoadBetweenSessionsOld)

Traceback (most recent call last):
File "/home/jie/ExeTera/tests/test_session.py", line 57, in test_create_then_load_categorical
self.assertDictEqual({1: b'a', 2: b'b'}, f.keys)
AssertionError: {1: b'a', 2: b'b'} != {1: 'a', 2: 'b'}

  • {1: b'a', 2: b'b'}
    ? - -
  • {1: 'a', 2: 'b'}

Ran 50 tests in 15.759s

FAILED (failures=2)
(base) jie@debian:~/ExeTera$ python --version
Python 3.8.5

Related code:
def test_create_then_load_categorical(self):
bio = BytesIO()
contents = [1, 2, 1, 2]
with session.Session() as s:
with h5py.File(bio, 'w') as src:
df = src.create_group('df')
f = s.create_categorical(df, 'foo', 'int8', {b'a': 1, b'b': 2})
f.data.write(np.array(contents))

    with session.Session() as s:
        with h5py.File(bio, 'r') as src:
            f = s.get(src['df']['foo'])
            self.assertListEqual(contents, f.data[:].tolist())
            **self.assertDictEqual({1: b'a', 2: b'b'}, f.keys)**

Seems python zip function put the byte array into string, so b'a' is not equals to 'a' hence unittest report error. This is ok when running python 3.7.5

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

No branches or pull requests

1 participant