forked from piskvorky/bounter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iterkeys, keys, iteritems, values, itervalues
- Loading branch information
Showing
3 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Author: Filip Stefanak <[email protected]> | ||
# Copyright (C) 2017 Rare Technologies | ||
# | ||
# This code is distributed under the terms and conditions | ||
# from the MIT License (MIT). | ||
|
||
import unittest | ||
|
||
from bounter import HashTable | ||
|
||
|
||
class HashTableIterationTest(unittest.TestCase): | ||
""" | ||
Functional tests for additional HashTable iterations methods, which all produce an iterator | ||
""" | ||
|
||
def setUp(self): | ||
self.ht = HashTable(buckets=64) | ||
self.ht.update([u"foo", u"bar", u"foo", "foo"]) | ||
self.keys = {u"foo", u"bar"} | ||
self.values = {3, 1} | ||
self.pairs = {(u"foo", 3), (u"bar", 1)} | ||
|
||
def test_keys(self): | ||
self.assertEqual(set(self.ht.keys()), self.keys) | ||
|
||
def test_iterkeys(self): | ||
self.assertEqual(set(self.ht.iterkeys()), self.keys) | ||
|
||
def test_values(self): | ||
self.assertEqual(set(self.ht.values()), self.values) | ||
|
||
def test_itervalues(self): | ||
self.assertEqual(set(self.ht.itervalues()), self.values) | ||
|
||
def test_items(self): | ||
self.assertEqual(set(self.ht.items()), self.pairs) | ||
|
||
def test_iteritems(self): | ||
self.assertEqual(set(self.ht.iteritems()), self.pairs) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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