root / elixir / tags / 0.7.0 / tests / test_py23compat.py

Revision 317, 0.8 kB (checked in by ged, 4 years ago)

Add tests for the py23compat (that I had forgotten to commit with the rest of
Jason's patch).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1from elixir.py23compat import *
2
3def test_set():
4    s = set(range(10) + range(5,11))
5    assert s == set(range(11))
6
7def test_sort_list_with_key():
8    l = ['foo', 'Fool', 'bar', 'Bark']
9    sort_list(l, key=str.lower)
10    assert l == ['bar', 'Bark', 'foo', 'Fool']
11
12def test_sort_list_with_key_and_reverse():
13    l = ['foo', 'Fool', 'bar', 'Bark']
14    sort_list(l, key=str.lower)
15    rl = list(l)
16    rl.reverse()
17    sort_list(l, key=str.lower, reverse=True)
18    assert l == rl
19
20def test_sorted():
21    l = ['foo', 'Fool', 'bar', 'Bark']
22    sl = sorted(l)
23    assert l != sl
24    l.sort()
25    assert l == sl
26
27def test_docstrings():
28    import elixir.py23compat
29    import doctest
30
31    failed, total = doctest.testmod(elixir.py23compat, verbose=False)
32    assert not failed
Note: See TracBrowser for help on using the browser.