forked from jfinkels/flask-restless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_helpers.py
38 lines (26 loc) · 963 Bytes
/
test_helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
tests.test_helpers
~~~~~~~~~~~~~~~~~~
Provides unit tests for the :mod:`flask_restless.helpers` module.
:copyright: 2012 Jeffrey Finkelstein <[email protected]>
:license: GNU AGPLv3+ or BSD
"""
from unittest2 import TestCase
from unittest2 import TestSuite
from flask.ext.restless.helpers import partition
__all__ = ['HelpersTest']
class HelpersTest(TestCase):
"""Unit tests for the helper functions."""
def test_partition(self):
"""Test for partitioning a list into two lists based on a given
condition.
"""
l = range(10)
left, right = partition(l, lambda x: x < 5)
self.assertEqual(list(range(5)), left)
self.assertEqual(list(range(5, 10)), right)
def load_tests(loader, standard_tests, pattern):
"""Returns the test suite for this module."""
suite = TestSuite()
suite.addTest(loader.loadTestsFromTestCase(HelpersTest))
return suite