From: Stefan Behnel Date: Sun, 14 Mar 2010 12:38:31 +0000 (+0100) Subject: test cleanup, include a test for cython.set X-Git-Tag: 0.13.beta0~291 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b51a74024bcbf3bf08b4fec4ca419a8def5983fc;p=cython.git test cleanup, include a test for cython.set --- diff --git a/tests/run/set.pyx b/tests/run/set.pyx index ab145137..9a0573e9 100644 --- a/tests/run/set.pyx +++ b/tests/run/set.pyx @@ -1,79 +1,90 @@ -__doc__ = u""" ->>> type(test_set_literal()) is _set -True ->>> sorted(test_set_literal()) -[u'a', u'b', 1] - ->>> type(test_set_add()) is _set -True ->>> sorted(test_set_add()) -[u'a', 1] - ->>> type(test_set_list_comp()) is _set -True ->>> sorted(test_set_list_comp()) -[0, 1, 2] - ->>> type(test_set_clear()) is _set -True ->>> list(test_set_clear()) -[] - ->>> type(test_set_pop()) is _set -True ->>> list(test_set_pop()) -[] - ->>> type(test_set_discard()) is _set -True ->>> sorted(test_set_discard()) -[u'12', 233] -""" - -import sys -if sys.version_info[0] >= 3: - __doc__ = __doc__.replace(u"u'", u"'").replace(u'u"', u'"') # Py2.3 doesn't have the 'set' builtin type, but Cython does :) _set = set +cimport cython + +def cython_set(): + """ + >>> cython_set() is _set + True + """ + assert set is cython.set + return cython.set + def test_set_literal(): - cdef set s1 = {1,u'a',1,u'b',u'a'} + """ + >>> type(test_set_literal()) is _set + True + >>> sorted(test_set_literal()) + ['a', 'b', 1] + """ + cdef set s1 = {1,'a',1,'b','a'} return s1 def test_set_add(): + """ + >>> type(test_set_add()) is _set + True + >>> sorted(test_set_add()) + ['a', 1] + """ cdef set s1 s1 = set([1]) s1.add(1) - s1.add(u'a') + s1.add('a') s1.add(1) return s1 def test_set_clear(): + """ + >>> type(test_set_clear()) is _set + True + >>> list(test_set_clear()) + [] + """ cdef set s1 s1 = set([1]) s1.clear() return s1 def test_set_list_comp(): + """ + >>> type(test_set_list_comp()) is _set + True + >>> sorted(test_set_list_comp()) + [0, 1, 2] + """ cdef set s1 s1 = set([i%3 for i in range(5)]) return s1 def test_set_pop(): + """ + >>> type(test_set_pop()) is _set + True + >>> list(test_set_pop()) + [] + """ cdef set s1 s1 = set() - s1.add(u'2') + s1.add('2') two = s1.pop() return s1 def test_set_discard(): + """ + >>> type(test_set_discard()) is _set + True + >>> sorted(test_set_discard()) + ['12', 233] + """ cdef set s1 s1 = set() - s1.add(u'12') + s1.add('12') s1.add(3) s1.add(233) - s1.discard(u'3') + s1.discard('3') s1.discard(3) return s1