File: test_py23compat.py

package info (click to toggle)
elixir 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 640 kB
  • ctags: 1,079
  • sloc: python: 4,936; makefile: 10
file content (32 lines) | stat: -rw-r--r-- 775 bytes parent folder | download
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
from elixir.py23compat import *

def test_set():
    s = set(range(10) + range(5,11))
    assert s == set(range(11))

def test_sort_list_with_key():
    l = ['foo', 'Fool', 'bar', 'Bark']
    sort_list(l, key=str.lower)
    assert l == ['bar', 'Bark', 'foo', 'Fool']

def test_sort_list_with_key_and_reverse():
    l = ['foo', 'Fool', 'bar', 'Bark']
    sort_list(l, key=str.lower)
    rl = list(l)
    rl.reverse()
    sort_list(l, key=str.lower, reverse=True)
    assert l == rl

def test_sorted():
    l = ['foo', 'Fool', 'bar', 'Bark']
    sl = sorted(l)
    assert l != sl
    l.sort()
    assert l == sl

def test_docstrings():
    import elixir.py23compat
    import doctest

    failed, total = doctest.testmod(elixir.py23compat, verbose=False)
    assert not failed