From 203c89aa6aeb61b1ea5296a58386f83f464fcdfb Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 29 Jan 2013 07:40:03 +0100 Subject: [PATCH] exclude test in Py2.4 --- runtests.py | 1 + tests/run/int_float_builtins_as_casts_T400.pyx | 34 ------------------------ tests/run/pynumber_subtype_conversion.pyx | 36 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 34 deletions(-) create mode 100644 tests/run/pynumber_subtype_conversion.pyx diff --git a/runtests.py b/runtests.py index 8d92ec7..0cbdf63 100755 --- a/runtests.py +++ b/runtests.py @@ -186,6 +186,7 @@ VER_DEP_MODULES = { 'run.relativeimport_T542', 'run.relativeimport_star_T542', 'run.initial_file_path', # relative import + 'run.pynumber_subtype_conversion', # bug in Py2.4 ]), (2,6) : (operator.lt, lambda x: x in ['run.print_function', 'run.language_level', # print function diff --git a/tests/run/int_float_builtins_as_casts_T400.pyx b/tests/run/int_float_builtins_as_casts_T400.pyx index beca903..c18ee01 100644 --- a/tests/run/int_float_builtins_as_casts_T400.pyx +++ b/tests/run/int_float_builtins_as_casts_T400.pyx @@ -137,37 +137,3 @@ def double_to_double_int(double x): """ cdef double r = int(x) return r - - -class MyFloat(float): - """ - >>> x = MyFloat(1.0) - >>> x - 1.0 - >>> float(x) - 12.0 - >>> x.float() - 12.0 - """ - def __float__(self): - return 12.0 - - def float(self): - return float(self) - - -class MyInt(int): - """ - >>> x = MyInt(1) - >>> x - 1 - >>> int(x) - 2 - >>> x.int() - 2 - """ - def __int__(self): - return 2 - - def int(self): - return int(self) diff --git a/tests/run/pynumber_subtype_conversion.pyx b/tests/run/pynumber_subtype_conversion.pyx new file mode 100644 index 0000000..48c00aa --- /dev/null +++ b/tests/run/pynumber_subtype_conversion.pyx @@ -0,0 +1,36 @@ +# mode: run +# tag: python, float, builtin + + +class MyFloat(float): + """ + >>> x = MyFloat(1.0) + >>> x + 1.0 + >>> float(x) + 12.0 + >>> x.float() + 12.0 + """ + def __float__(self): + return 12.0 + + def float(self): + return float(self) + + +class MyInt(int): + """ + >>> x = MyInt(1) + >>> x + 1 + >>> int(x) + 2 + >>> x.int() + 2 + """ + def __int__(self): + return 2 + + def int(self): + return int(self) -- 2.7.4