Skip to content

Commit 0573b67

Browse files
authored
Enable some test_descr tests (#1734)
1 parent 132ff7c commit 0573b67

File tree

4 files changed

+75
-2
lines changed

4 files changed

+75
-2
lines changed

Src/IronPython/Runtime/Operations/ObjectOps.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,12 @@ private static int GetTypeSize(Type t) {
215215
/// Returns a friendly string representation of the object.
216216
/// </summary>
217217
public static string __str__(CodeContext/*!*/ context, object o) {
218-
return PythonOps.Repr(context, o);
218+
try {
219+
PythonOps.FunctionPushFrame(context.LanguageContext);
220+
return PythonOps.Repr(context, o);
221+
} finally {
222+
PythonOps.FunctionPopFrame();
223+
}
219224
}
220225

221226
public static NotImplementedType __subclasshook__(params object[] args) {

Src/IronPythonTest/Cases/CPythonCasesManifest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ Ignore=true
322322
IsolationLevel=PROCESS # https://github.com/IronLanguages/ironpython3/issues/489
323323
RetryCount=2
324324

325-
[CPython.test_descr]
325+
[CPython.test_descr] # IronPython.test_descr_stdlib
326326
IsolationLevel=ENGINE
327327
MaxRecursion=100
328328
Ignore=true

Src/IronPythonTest/Cases/IronPythonCasesManifest.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Reason=disabled in IronLanguages/main, needs lots of work
2828
[IronPython.test_delegate]
2929
RetryCount=2
3030

31+
[IronPython.test_descr_stdlib]
32+
IsolationLevel=ENGINE
33+
MaxRecursion=100
34+
3135
[IronPython.test_doc]
3236
RunCondition=NOT $(IS_OSX) # TODO: figure out
3337
IsolationLevel=PROCESS # required to have quit/exit

Tests/test_descr_stdlib.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Licensed to the .NET Foundation under one or more agreements.
2+
# The .NET Foundation licenses this file to you under the Apache 2.0 License.
3+
# See the LICENSE file in the project root for more information.
4+
5+
##
6+
## Run selected tests from test_descr from StdLib
7+
##
8+
9+
from iptest import is_ironpython, generate_suite, run_test
10+
11+
import test.test_descr
12+
13+
def load_tests(loader, standard_tests, pattern):
14+
tests = loader.loadTestsFromModule(test.test_descr)
15+
16+
if is_ironpython:
17+
failing_tests = [
18+
test.test_descr.ClassPropertiesAndMethods('test_altmro'), # NotImplementedError: Overriding type.mro is not implemented
19+
test.test_descr.ClassPropertiesAndMethods('test_classmethods'), # AttributeError: 'classmethod' object has no attribute '__dict__'
20+
test.test_descr.ClassPropertiesAndMethods('test_cycle_through_dict'), # NotImplementedError: gc.get_objects isn't implemented
21+
test.test_descr.ClassPropertiesAndMethods('test_descrdoc'), # AssertionError: 'True if the file is closed\r\n' != 'True if the file is closed'
22+
test.test_descr.ClassPropertiesAndMethods('test_init'), # AssertionError: did not test __init__() for None return
23+
test.test_descr.ClassPropertiesAndMethods('test_metaclass'), # AttributeError: 'type' object has no attribute '__get__'
24+
test.test_descr.ClassPropertiesAndMethods('test_method_wrapper'), # AssertionError: <built-in method __add__ of list object at 0x000000000000003E> != <built-in method __add__ of list object at 0x000000000000003F>
25+
test.test_descr.ClassPropertiesAndMethods('test_mutable_bases'), # AttributeError: 'E' object has no attribute 'meth'
26+
test.test_descr.ClassPropertiesAndMethods('test_mutable_bases_catch_mro_conflict'), # AssertionError: didn't catch MRO conflict
27+
test.test_descr.ClassPropertiesAndMethods('test_mutable_bases_with_failing_mro'), # NotImplementedError: Overriding type.mro is not implemented
28+
test.test_descr.ClassPropertiesAndMethods('test_properties'), # AssertionError: expected AttributeError from trying to set readonly '__doc__' attr on a property
29+
test.test_descr.ClassPropertiesAndMethods('test_proxy_call'), # AssertionError: TypeError not raised
30+
test.test_descr.ClassPropertiesAndMethods('test_qualname'), # AssertionError: 'member_descriptor' != 'getset_descriptor'
31+
test.test_descr.ClassPropertiesAndMethods('test_qualname_dict'), # AssertionError: 'Foo' != 'some.name'
32+
test.test_descr.ClassPropertiesAndMethods('test_set_and_no_get'), # https://github.com/IronLanguages/ironpython3/issues/1722
33+
test.test_descr.ClassPropertiesAndMethods('test_set_class'), # AssertionError: shouldn't allow <J object at 0x000000000000004B>.__class__ = <class 'test.test_descr.J'>
34+
test.test_descr.ClassPropertiesAndMethods('test_set_dict'), # AssertionError: shouldn't allow <class 'test.test_descr.D'>.__dict__ = {}
35+
test.test_descr.ClassPropertiesAndMethods('test_set_doc'), # AttributeError: readonly attribute
36+
test.test_descr.ClassPropertiesAndMethods('test_special_method_lookup'), # AssertionError: __getattribute__ called with __iter__
37+
test.test_descr.ClassPropertiesAndMethods('test_slots'), # NotImplementedError: gc.get_objects isn't implemented
38+
test.test_descr.ClassPropertiesAndMethods('test_slots_descriptor'), # SystemError: Object reference not set to an instance of an object.
39+
test.test_descr.ClassPropertiesAndMethods('test_staticmethods'), # AttributeError: 'staticmethod' object has no attribute '__dict__'
40+
test.test_descr.ClassPropertiesAndMethods('test_supers'), # AttributeError: 'mysuper' object has no attribute 'meth'
41+
test.test_descr.ClassPropertiesAndMethods('test_vicious_descriptor_nonsense'), # AssertionError: True is not false : <C object at 0x0000000000000058> has unexpected attribute 'attr'
42+
test.test_descr.MiscTests('test_type_lookup_mro_reference'), # AssertionError: 'from Base' != 'from Base2'
43+
test.test_descr.MroTest('test_incomplete_extend'), # NotImplementedError: Overriding type.mro is not implemented
44+
test.test_descr.MroTest('test_incomplete_set_bases_on_self'), # NotImplementedError: Overriding type.mro is not implemented
45+
test.test_descr.MroTest('test_incomplete_super'), # NotImplementedError: Overriding type.mro is not implemented
46+
test.test_descr.MroTest('test_reent_set_bases_on_base'), # NotImplementedError: Overriding type.mro is not implemented
47+
test.test_descr.MroTest('test_reent_set_bases_on_direct_base'), # NotImplementedError: Overriding type.mro is not implemented
48+
test.test_descr.MroTest('test_reent_set_bases_tp_base_cycle'), # NotImplementedError: Overriding type.mro is not implemented
49+
test.test_descr.MroTest('test_tp_subclasses_cycle_error_return_path'), # NotImplementedError: Overriding type.mro is not implemented
50+
test.test_descr.MroTest('test_tp_subclasses_cycle_in_update_slots'), # NotImplementedError: Overriding type.mro is not implemented
51+
test.test_descr.PicklingTests('test_issue24097'), # TypeError: __reduce__() takes exactly 1 argument (1 given)
52+
test.test_descr.PicklingTests('test_reduce'), # AssertionError: Tuples differ: (<function __newobj__ at 0x00000000000000AB>, (<class 'test.t[31 chars]None) != (<function __newobj_ex__ at 0x00000000000000AC>, (<class 'tes[40 chars]None)
53+
test.test_descr.PicklingTests('test_reduce_copying'), # TypeError: __getnewargs__() takes exactly 1 argument (2 given)
54+
test.test_descr.PicklingTests('test_special_method_lookup'), # AssertionError: Tuples differ: (<fun[19 chars] 0x00000000000000AB>, (<class 'test.test_descr.Picky'>,), None) != (<fun[19 chars] 0x00000000000000AB>, (<class 'test.test_descr.Picky'>,), {})
55+
]
56+
57+
skip_tests = []
58+
59+
return generate_suite(tests, failing_tests, skip_tests)
60+
61+
else:
62+
return tests
63+
64+
run_test(__name__)

0 commit comments

Comments
 (0)