test_autodict.py 367 B

12345678910111213141516
  1. # -*- coding: utf-8 -*-
  2. import pytest
  3. from ioex import AutoDict
  4. def test_assign():
  5. d = AutoDict()
  6. assert d == {}
  7. d['A'] = 1
  8. assert d == {'A': 1}
  9. d['B'][2] = 'b'
  10. assert d == {'A': 1, 'B': {2: 'b'}}
  11. del d['A']
  12. assert d == {'B': {2: 'b'}}
  13. d['C'][3]['c'] = ('Γ', 'γ')
  14. assert d == {'B': {2: 'b'}, 'C': {3: {'c': ('Γ', 'γ')}}}