Skip to content

Instantly share code, notes, and snippets.

@WonderCsabo
Forked from anonymous/OrderedDictTest
Created November 6, 2014 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WonderCsabo/96ee19cbd5b68366738b to your computer and use it in GitHub Desktop.
Save WonderCsabo/96ee19cbd5b68366738b to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 6 16:24:22 2014
@author: wondercsabo
"""
import unittest
from collections import OrderedDict
from functools import reduce
class OrderedDictTest(unittest.TestCase):
def setUp(self):
self.sut = OrderedDict()
def test_ConstructorShouldCreateEmpty(self):
self.assertEqual(0, len(self.sut))
def test_getShouldRaiseWhenKeyNotExist(self):
self.assertRaises(KeyError, lambda: self.sut["key"])
def test_iterateShouldRetainOrder(self):
self.sut["key1"] = 1
self.sut["key2"] = 2
self.assertEqual(
['key1', 1, 'key2', 2],
list(reduce(lambda x, y: x + y, self.sut.items())))
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment