From a63120f5223919c73ba0e49977c18d5ce0ab91cc Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 16 Feb 2008 12:33:27 +0100 Subject: [PATCH] new tests for various unicode()/str() usage patterns --- tests/run/strfunction.pyx | 35 ++++++++++++++++++++++++++++++++++ tests/run/unicodefunction.pyx | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 tests/run/strfunction.pyx create mode 100644 tests/run/unicodefunction.pyx diff --git a/tests/run/strfunction.pyx b/tests/run/strfunction.pyx new file mode 100644 index 00000000..2ed6e980 --- /dev/null +++ b/tests/run/strfunction.pyx @@ -0,0 +1,35 @@ +__doc__ = """ + >>> s('test') + 'test' + >>> z + 'test' + >>> c('testing') + 'testing' + >>> sub('testing a subtype') + 'testing a subtype' + >>> subs('testing a subtype') + 'testing a subtype' + +# >>> csub('testing a subtype') +# 'testing a subtype' +# >>> csubs('testing a subtype') +# 'testing a subtype' +""" + +s = str +z = str('test') + +def c(string): + return str(string) + +class subs(str): + pass + +def sub(string): + return subs(string) + +#cdef class subs(str): +# pass + +#def csub(string): +# return csubs(string) diff --git a/tests/run/unicodefunction.pyx b/tests/run/unicodefunction.pyx new file mode 100644 index 00000000..fe490dff --- /dev/null +++ b/tests/run/unicodefunction.pyx @@ -0,0 +1,36 @@ +__doc__ = """ + >>> u('test') + u'test' + >>> z + u'test' + >>> c('testing') + u'testing' + >>> subu('testing a Python subtype') + u'testing a Python subtype' + >>> sub('testing a Python subtype') + u'testing a Python subtype' + +# >>> csubu('testing a C subtype') +# u'testing a C subtype' +# >>> csub('testing a C subtype') +# u'testing a C subtype' +""" + +u = unicode +z = unicode('test') + +def c(string): + return unicode(string) + +class subu(unicode): + pass + +def sub(string): + return subu(string) + +#cdef class csubu(unicode): +# pass + +#def csub(string): +# return csubu(string) + -- 2.26.2