-
-
Save WonderCsabo/96ee19cbd5b68366738b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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