File: test_bunch.py

package info (click to toggle)
python-mne 1.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 131,492 kB
  • sloc: python: 213,302; javascript: 12,910; sh: 447; makefile: 144
file content (24 lines) | stat: -rw-r--r-- 633 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Authors: The MNE-Python contributors.
# License: BSD-3-Clause
# Copyright the MNE-Python contributors.

import pickle

from mne.utils import BunchConstNamed
from mne.utils._bunch import NamedFloat, NamedInt


def test_pickle():
    """Test if BunchConstNamed object can be pickled."""
    b1 = BunchConstNamed()
    b1.x = 1
    b1.y = 2.12
    assert isinstance(b1.x, int)
    assert isinstance(b1.x, NamedInt)
    assert repr(b1.x) == "1 (x)"
    assert isinstance(b1.y, float)
    assert isinstance(b1.y, NamedFloat)
    assert repr(b1.y) == "2.12 (y)"

    b2 = pickle.loads(pickle.dumps(b1))  # nosec B301
    assert b1 == b2