Skip to content

Commit 0e17cb7

Browse files
committed
[roottest] Remove python tests that are redundant with the cppyy tests
The tests under roottest/python and the upstream cppyy test suite (bindings/pyroot/cppyy/cppyy/test/) both descend from the original PyROOT test suite by Wim Lavrijsen, so a large fraction of roottest/python duplicated coverage that already exists upstream (often verbatim, with identical helper classes). This commit deletes the redundant tests so that roottest/python only keeps ROOT-specific tests and the few cppyy-level tests that have no (green) upstream equivalent yet. Superseded tests, per file (upstream paths are relative to bindings/pyroot/cppyy/cppyy/test/ unless noted as pythonizations/test/, which is bindings/pyroot/pythonizations/test/): basic/PyROOT_basictests.py: - Basic3PythonLanguageTestCase.test1HaveDocString -> test_fragile.py::test10_documentation, test_doc_features.py::test_doc_strings - Basic3PythonLanguageTestCase.test2BoundUnboundMethodCalls -> test_pythonify.py::test14_bound_unbound_calls (near line-for-line) - Basic3PythonLanguageTestCase.test3ThreadingSupport -> test_concurrent.py (several tests set __release_gil__) - Basic3PythonLanguageTestCase.test4ClassAndTypedefEquality -> test_regression.py::test08_typedef_identity (same PyABC idiom) - Basic4ArgumentPassingTestCase.test1-test8 (TString/TLorentzVector by value/ref, interpreted and ACLiC-compiled, default arguments) -> test_pythonify.py::test10_default_arguments, test_advancedcpp.py::test01_default_arguments and test07_pass_by_reference (the interpreted-vs-compiled axis is not a distinct binding behavior in cppyy, which always JITs via cling) - Basic4ArgumentPassingTestCase.test9ByRefPassing -> test_lowlevel.py::test05_array_as_ref - Basic6ReturnValueTestCase.test1ReturnIntegers -> test_datatypes.py::test01_instance_data_read_access (get_*_r) - helper files ArgumentPassingInterpreted.C, ArgumentPassingCompiled.C and ReturnValues.C removed with their tests basic/PyROOT_datatypetest_numpy.py: - test02_boolarray2cpp (ROOT-10731) -> test_lowlevel.py::test09_numpy_bool_array (same test) - test03_arraydatamember_lifeline (#7501) -> test_datatypes.py::test44_buffer_memory_handling function/PyROOT_functiontests.py: - Func3GlobalCppFunctionTestCase.test1-test5 (global, namespaced, compiled global functions; namespace update from later dictionary) -> test_pythonify.py::test08_global_functions, test_advancedcpp.py::test03_namespaces and test03a_namespace_lookup_on_update - Func4GlobalCppFunctionAsMethodTestCase.test1/test2 -> test_pythonify.py::test15_installable_function - helper files GlobalFunction.C, GlobalFunction2.C, GlobalFunction3.C, InstallableFunction.C removed with their tests cpp/PyROOT_advancedtests.py (AdvancedCpp.C maps 1:1 onto upstream advancedcpp.h: PR_B->b_class, RefTester->ref_tester, Convertible->some_convertible, Comparable->some_comparable, ...): - Cpp01Inheritence.test1DataMembers -> test_advancedcpp.py::test06_datamembers - Cpp01Inheritence.test2PassByReference -> test_advancedcpp.py::test07_pass_by_reference - Cpp02TemplateLookup.test01/test02 -> test_advancedcpp.py::test04_template_types - Cpp02TemplateLookup.test03 -> test_advancedcpp.py::test15_template_instantiation_with_vector_of_float - Cpp02TemplateLookup.test04-test07 -> test_templates.py::test01_template_member_functions - Cpp02TemplateLookup.test08 -> test_advancedcpp.py::test16_template_global_functions, test_templates.py::test03_templated_function - Cpp02TemplateLookup.test09 -> test_templates.py::test33_using_template_argument, test34_cstring_template_argument - Cpp02TemplateLookup.test10 -> test_templates.py::test03_templated_function - Cpp02TemplateLookup.test11 -> test_templates.py::test04_variadic_function - Cpp03PassByNonConstRef.test2 -> test_lowlevel.py::test06_ctypes_as_ref_and_ptr - Cpp03PassByNonConstRef.test3 -> test_datatypes.py/test_conversions.py const-ref conversions - Cpp04HandlingAbstractClasses.test1/test2 -> test_advancedcpp.py::test05_abstract_classes - Cpp05AssignToRefArbitraryClass.test1AssignToReturnByRef -> test_advancedcpp.py::test17_assign_to_return_byref - Cpp06MathConverters.test1 -> test_advancedcpp.py::test18_math_converters - Cpp07GloballyOverloadedComparator.test1 -> test_advancedcpp.py::test19_comparator - Cpp07GloballyOverloadedComparator.test2 -> test_operators.py::test16_global_ordered_operators - Cpp09LongExpressions.test1 -> test_advancedcpp.py::test10_object_identity - Cpp10StandardExceptions.test1 -> test_stltypes.py (std::exception) and test_regression.py::test49_overloads_with_runtime_errors - Cpp11PointerContainers.test1 -> test_advancedcpp.py::test10_object_identity and test_stltypes.py vector-of-pointers tests - Cpp13OverloadedNewDelete.test1 -> test_advancedcpp.py::test14_new_overloader - helper file Template.C removed with the template tests Kept without upstream equivalent: Cpp05.test2NiceErrorMessageReturnByRef, Cpp07.test3DirectUseComparator, Cpp10.test2ExceptionBoolValue, Cpp12NamespaceLazyFunctions, Cpp14CopyConstructorOrdering. Cpp08 GlobalVariables is kept although covered by test_advancedcpp.py::test21_access_to_global_variables because that upstream test is currently marked xfail. cpp/PyROOT_cpptests.py: - test01ClassEnum, test02Globalenum, test03GlobalEnumType, test05EnumSignedUnsigned -> test_datatypes.py::test10_enum, test11_typed_enums; test_regression.py::test24_C_style_enum - test08ObjectValidity -> test_datatypes.py::test21_object_validity - test11Namespaces -> test_advancedcpp.py::test03_namespaces and test03a_namespace_lookup_on_update - test12VoidPointerPassing -> test_advancedcpp.py::test08_void_pointer_passing - test15ObjectAndPointerComparisons -> test_datatypes.py::test19_object_and_pointer_comparisons - Cpp2ClassNamingTestCase.test01Underscore -> test_pythonify.py::test13_underscore_in_class_name (identical z_) - Cpp2ClassNamingTestCase.test02DefaultCtorInNamespace -> test_advancedcpp.py::test01_default_arguments - Cpp2ClassNamingTestCase.test04NamespacedTemplateIdentity -> test_advancedcpp.py::test04_template_types - Cpp4InheritanceTreeOverloadResolution.test1SingleArgumentFunction (root-8817) -> test_overloads.py::test11_deep_inheritance - helper files PointerPassing.C and Namespace2.C removed with their tests Kept: test04NsEnumType and test06ScopedEnum (upstream test_datatypes.py::test12_enum_scopes is currently xfail), the ROOT-specific tests (TLorentzVector copy ctor with the PyROOT MakeNullPointer/__assign__ API, TVectorF/TMatrixD element access, TROOT statics, PyConfig.ExposeCppMacros, AsCObject/BindObject, AddressOf, TGraphMultiErrors/TH1F using declarations), and the uncovered Cpp2.test03NamespaceInTemplates and Cpp4.test2TwoArgumentFunctionAmbiguous. pythonizations/PyROOT_pythonizationtest.py: - TestClassPYTHONIZATIONS.test01_size_mapping -> test_pythonization.py::test01_size_mapping (verbatim; the helper MyBufferReturner is byte-identical to NakedBuffers in upstream pythonizables.h) - TestClassPYTHONIZATIONS.test02_type_pinning -> test_pythonization.py::test03_type_pinning (verbatim, identical MyBase/MyDerived/GimeDerived helpers) - TestClassPYTHONIZATIONS_FRAGILITY: empty class with no tests, dropped - TestClassROOT_PYTHONIZATIONS.test01_tgraph -> pythonizations/test/tgraph_getters.py - TestClassROOT_PYTHONIZATIONS.test03_th2 (ROOT-10109) -> pythonizations/test/th2.py::test_GetBinError - helper files Pythonizables.C/.h removed (upstream has identical copies) Kept: test02_tfile (RooWorkspace/TFile read-back lifetime, not covered). memory/PyROOT_memorytests.py: - test3ObjectCallHeuristics -> test_regression.py::test44_heuristic_mem_policy (same CallRef/CallConstRef/CallPtr/CallConstPtr pattern and SetHeuristicMemoryPolicy round-trip) - test4DestructionOfDerivedClass -> test_crossinheritance.py::test12a_counter_test and test13_virtual_dtors_and_del Kept: test1ObjectCreationDestruction (bound-method keep-alive nuance is not covered upstream). regression/PyROOT_regressiontests.py: - Regression03OldCrashers.test6InspectionOfTH1I (ROOT-7336) -> test_regression.py::test02_dir, test_fragile.py::test11_dir - Regression05LoKiNamespace.test1/test2/test3 (ROOT-10256, ROOT-10292) -> test_advancedcpp.py::test04_template_types and test16_template_global_functions; test_templates.py::test01_template_member_functions, test03_templated_function, test07_type_deduction - Regression06Int64Conversion.test1/test2 -> test_datatypes.py::test07_type_conversions (set_ulong/ullong) - Regression07MatchConstWithProperReturn.test1 -> test_advancedcpp.py::test20_overload_order_with_proper_return (identical overload_one_way/overload_the_other_way classes) - Regression08CheckEnumExactMatch.test1 -> test_datatypes.py::test10_enum, test12_enum_scopes - Regression11GlobalsLookup.test1GetCout -> test_streams.py::test02_std_cout - Regression15ConsRef.test1 -> test_datatypes.py::test07_type_conversions (set_*_cr const-ref conversions) - Regression16NestedNamespace.test1 -> test_fragile.py::test12_imports (fragile::nested1::nested2::nested3) and test30_two_nested_ambiguity - Regression18FailingDowncast.test1 -> test_advancedcpp.py::test12_actual_type and test13_actual_type_virtual_multi - Regression21ReuseProxies.test1 (ROOT-8843) -> test_advancedcpp.py::test10_object_identity (refers_to_self) - Regression24CppPythonInheritance tests 01-07, 09, 10 (ROOT-10872, ROOT-11010, ROOT-10789, #6376, #6467, #6345, #6470) -> test_crossinheritance.py: test24_non_copyable (deleted copy ctor and move ctor), test14_protected_access, test13_virtual_dtors_and_del, test35_deletion, test02_constructor, test19_cpp_side_multiple_inheritance, test20_basic_multiple_inheritance, test22_multiple_inheritance_with_defaults, test30_access_and_overload, test17_deep_hierarchy, test28_cross_deep - Cpp3TemplatedMathOperatorsTestCase.test01LorentzVector -> test_templates.py::test19_templated_operator_add - helper files Scott2.C, Till.C, ULongLong.C, LoKiNamespace.C and NestedNamespace.h removed with their tests Kept: the ROOT-specific tests (import-star, threading/GUI-thread rules, TVector3/TMatrixD pythonizations, TFile/TGraph I/O, TGL, gEnv, TMultiGraph cleanup, TFractionFitter, TGMainFrame ctor) and the tests without upstream equivalent (PyException propagation, MuonTileID temporary, namespaced iterator pythonization, no-loop operator*, metaclass access, CoralAttributeList base iterators, direct PyException construction, mixed Python+C++ multiple inheritance, operator[] vs operator() shadowing #7179, using-decl operator(), smart-ptr overload selection #15117). The CMakeLists.txt files were updated to drop the removed helper macros from COPY_TO_BUILDDIR/PRECMD. All remaining suites (basic, datatype-numpy, function, cpp, advanced, pythonizations, memory, regression) were run against the build tree and pass. 🤖 Done with the help of AI.
1 parent 28b3942 commit 0e17cb7

30 files changed

Lines changed: 81 additions & 2182 deletions

roottest/python/basic/ArgumentPassingCompiled.C

Lines changed: 0 additions & 64 deletions
This file was deleted.

roottest/python/basic/ArgumentPassingInterpreted.C

Lines changed: 0 additions & 56 deletions
This file was deleted.

roottest/python/basic/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
if(pyroot)
22
ROOTTEST_ADD_TEST(basic
33
MACRO PyROOT_basictests.py
4-
COPY_TO_BUILDDIR ArgumentPassingCompiled.C ReturnValues.C SimpleClass.C ArgumentPassingInterpreted.C
5-
PRECMD ${ROOT_root_CMD} -b -q -e .L\ ArgumentPassingCompiled.C+)
4+
COPY_TO_BUILDDIR SimpleClass.C)
65

76
if(NOT MSVC OR win_broken_tests)
87
ROOTTEST_ADD_TEST(datatype-numpy

roottest/python/basic/PyROOT_basictests.py

Lines changed: 1 addition & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010

1111
import ROOT
1212
from ROOT import gROOT, gApplication, gSystem, gInterpreter, gDirectory
13-
from ROOT import TLorentzVector, TCanvas, TString, TList, TH1D, TObjArray, TVectorF, TObjString
13+
from ROOT import TLorentzVector, TString, TList, TH1D, TObjArray, TVectorF, TObjString
1414
from common import *
1515

1616
__all__ = [
1717
'Basic1ModuleTestCase',
1818
'Basic2SetupTestCase',
19-
'Basic3PythonLanguageTestCase',
20-
'Basic4ArgumentPassingTestCase',
2119
'Basic5PythonizationTestCase',
22-
'Basic6ReturnValueTestCase',
2320
]
2421

2522
def setup_module(mod):
@@ -103,159 +100,6 @@ def test5MacroLoading( self ):
103100
self.assertEqual( c.GetData(), 13 )
104101

105102

106-
### basic python language features test cases ================================
107-
class Basic3PythonLanguageTestCase( MyTestCase ):
108-
def test1HaveDocString( self ):
109-
"""Test doc strings existence"""
110-
111-
self.assertTrue( hasattr( TCanvas, "__doc__" ) )
112-
self.assertTrue( hasattr( TCanvas.__init__, "__doc__" ) )
113-
114-
def test2BoundUnboundMethodCalls( self ):
115-
"""Test (un)bound method calls"""
116-
117-
self.assertRaises( TypeError, TLorentzVector.X )
118-
119-
m = TLorentzVector.X
120-
self.assertRaises( TypeError, m )
121-
self.assertRaises( TypeError, m, 1 )
122-
123-
b = TLorentzVector()
124-
b.SetX( 1.0 )
125-
self.assertEqual( 1.0, m( b ) )
126-
127-
def test3ThreadingSupport( self ):
128-
"""Test whether the GIL can be properly released"""
129-
130-
try:
131-
gROOT.GetVersion._threaded = 1
132-
except AttributeError:
133-
# Attribute name change in new Cppyy
134-
gROOT.GetVersion.__release_gil__ = 1
135-
136-
gROOT.GetVersion()
137-
138-
def test4ClassAndTypedefEquality( self ):
139-
"""Typedefs of the same class must point to the same python class"""
140-
141-
gInterpreter.Declare( """namespace PyABC {
142-
struct SomeStruct {};
143-
struct SomeOtherStruct {
144-
typedef std::vector<const PyABC::SomeStruct*> StructContainer;
145-
};
146-
}""" )
147-
148-
import cppyy
149-
PyABC = cppyy.gbl.PyABC
150-
151-
self.assertTrue( PyABC.SomeOtherStruct.StructContainer is cppyy.gbl.std.vector('const PyABC::SomeStruct*') )
152-
153-
154-
### basic C++ argument basic (value/ref and compiled/interpreted) ============
155-
class Basic4ArgumentPassingTestCase( MyTestCase ):
156-
def test1TStringByValueInterpreted( self ):
157-
"""Test passing a TString by value through an interpreted function"""
158-
159-
gROOT.LoadMacro( 'ArgumentPassingInterpreted.C' )
160-
161-
f = ROOT.InterpretedTest.StringValueArguments
162-
163-
self.assertEqual( f( 'aap' ), 'aap' )
164-
self.assertEqual( f( TString( 'noot' ) ), 'noot' )
165-
self.assertEqual( f( 'zus', 1, 'default' ), 'default' )
166-
self.assertEqual( f( 'zus', 1 ), 'default' )
167-
self.assertEqual( f( 'jet', 1, TString( 'teun' ) ), 'teun' )
168-
169-
def test2TStringByRefInterpreted( self ):
170-
"""Test passing a TString by reference through an interpreted function"""
171-
172-
# script ArgumentPassingInterpreted.C already loaded in by value test
173-
174-
f = ROOT.InterpretedTest.StringRefArguments
175-
176-
self.assertEqual( f( 'aap' ), 'aap' )
177-
self.assertEqual( f( TString( 'noot' ) ), 'noot' )
178-
self.assertEqual( f( 'zus', 1, 'default' ), 'default' )
179-
self.assertEqual( f( 'zus', 1 ), 'default' )
180-
self.assertEqual( f( 'jet', 1, TString( 'teun' ) ), 'teun' )
181-
182-
def test3TLorentzVectorByValueInterpreted( self ):
183-
"""Test passing a TLorentzVector by value through an interpreted function"""
184-
185-
# script ArgumentPassingInterpreted.C already loaded in by value test
186-
187-
f = ROOT.InterpretedTest.LorentzVectorValueArguments
188-
189-
self.assertEqual( f( TLorentzVector( 5, 6, 7, 8 ) ), TLorentzVector( 5, 6, 7, 8 ) )
190-
self.assertEqual( f( TLorentzVector(), 1 ), TLorentzVector( 1, 2, 3, 4 ) )
191-
192-
def test4TLorentzVectorByRefInterpreted( self ):
193-
"""Test passing a TLorentzVector by reference through an interpreted function"""
194-
195-
# script ArgumentPassingInterpreted.C already loaded in by value test
196-
197-
f = ROOT.InterpretedTest.LorentzVectorRefArguments
198-
199-
self.assertEqual( f( TLorentzVector( 5, 6, 7, 8 ) ), TLorentzVector( 5, 6, 7, 8 ) )
200-
self.assertEqual( f( TLorentzVector(), 1 ), TLorentzVector( 1, 2, 3, 4 ) )
201-
202-
def test5TStringByValueCompiled( self ):
203-
"""Test passing a TString by value through a compiled function"""
204-
205-
gROOT.LoadMacro( 'ArgumentPassingCompiled.C++' )
206-
207-
f = ROOT.CompiledTest.StringValueArguments
208-
209-
self.assertEqual( f( 'aap' ), 'aap' )
210-
self.assertEqual( f( TString( 'noot' ) ), 'noot' )
211-
self.assertEqual( f( 'zus', 1, 'default' ), 'default' )
212-
self.assertEqual( f( 'zus', 1 ), 'default' )
213-
self.assertEqual( f( 'jet', 1, TString( 'teun' ) ), 'teun' )
214-
215-
def test6TStringByRefCompiled( self ):
216-
"""Test passing a TString by reference through a compiled function"""
217-
218-
# script ArgumentPassingCompiled.C already loaded in by value test
219-
220-
f = ROOT.CompiledTest.StringRefArguments
221-
222-
self.assertEqual( f( 'aap' ), 'aap' )
223-
self.assertEqual( f( TString( 'noot' ) ), 'noot' )
224-
self.assertEqual( f( 'zus', 1, 'default' ), 'default' )
225-
self.assertEqual( f( 'zus', 1 ), 'default' )
226-
self.assertEqual( f( 'jet', 1, TString( 'teun' ) ), 'teun' )
227-
228-
def test7TLorentzVectorByValueCompiled( self ):
229-
"""Test passing a TLorentzVector by value through a compiled function"""
230-
231-
# script ArgumentPassingCompiled.C already loaded in by value test
232-
233-
f = ROOT.CompiledTest.LorentzVectorValueArguments
234-
235-
self.assertEqual( f( TLorentzVector( 5, 6, 7, 8 ) ), TLorentzVector( 5, 6, 7, 8 ) )
236-
self.assertEqual( f( TLorentzVector(), 1 ), TLorentzVector( 1, 2, 3, 4 ) )
237-
238-
def test8TLorentzVectorByRefCompiled( self ):
239-
"""Test passing a TLorentzVector by reference through a compiled function"""
240-
241-
# script ArgumentPassingCompiled.C already loaded in by value test
242-
243-
f = ROOT.CompiledTest.LorentzVectorRefArguments
244-
245-
self.assertEqual( f( TLorentzVector( 5, 6, 7, 8 ) ), TLorentzVector( 5, 6, 7, 8 ) )
246-
self.assertEqual( f( TLorentzVector(), 1 ), TLorentzVector( 1, 2, 3, 4 ) )
247-
248-
def test9ByRefPassing( self ):
249-
"""Test passing by-reference of builtin types"""
250-
251-
import array, sys
252-
253-
if 'linux' in sys.platform:
254-
a = array.array('I',[0])
255-
val = ROOT.CompiledTest.UnsignedIntByRef( a )
256-
self.assertEqual( a[0], val )
257-
258-
259103
### basic extension features test cases ======================================
260104
class Basic5PythonizationTestCase( MyTestCase ):
261105
def test1Strings( self ):
@@ -419,20 +263,6 @@ def test5Hashing( self ):
419263
a = TH1D("asd", "asd", 10, 0, 1)
420264
self.assertTrue( hash(a) )
421265

422-
### basic C++ return integer types ============
423-
class Basic6ReturnValueTestCase( MyTestCase ):
424-
def test1ReturnIntegers( self ):
425-
"""Test returning all sort of interger types"""
426-
427-
gROOT.LoadMacro( 'ReturnValues.C' )
428-
429-
tests = ROOT.testIntegerResults()
430-
for type in ["short", "int", "long", "longlong"]:
431-
for name, value in [("PlusOne", 1), ("MinusOne", -1)]:
432-
member = "%s%s" % (type, name)
433-
result = getattr(tests, member)()
434-
self.assertEqual(result, value , '%s() == %s, should be %s' % (member, result, value))
435-
436266

437267
## actual test run
438268
if __name__ == '__main__':

roottest/python/basic/PyROOT_datatypetest_numpy.py

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,40 +55,10 @@ def test01_buffer_to_numpy(self):
5555
arr[N-1] = val
5656
assert arr[N-1] == np_arr[N-1] == val
5757

58-
def test02_boolarray2cpp(self):
59-
'''
60-
Pass an bool array to a C++ function taking a bool*
61-
Fixes ROOT-10731
62-
'''
63-
import numpy as np
64-
import cppyy
65-
cppyy.cppdef('int convert(bool* x) { return x[0]; }')
66-
x1 = np.array([True], '?') # bool
67-
x2 = np.array([True], 'b') # signed char, treated as bool before
68-
y1 = cppyy.gbl.convert(x1)
69-
y2 = cppyy.gbl.convert(x2)
70-
assert y1 == 1
71-
assert y2 == 1
72-
73-
def test03_arraydatamember_lifeline(self):
74-
"""Test setting of lifeline for array data members"""
75-
# 7501
76-
77-
import numpy as np
78-
import cppyy
79-
cppyy.cppdef("""
80-
class array_ll {
81-
public:
82-
float *v1 = nullptr;
83-
float *v2 = nullptr;
84-
};
85-
""")
86-
a = cppyy.gbl.array_ll()
87-
a.v1 = np.array([1, 2], dtype=np.float32)
88-
a.v2 = np.array([3, 4], dtype=np.float32)
89-
90-
assert a.v1[0] == 1
91-
assert a.v1[1] == 2
58+
# NOTE: former test02_boolarray2cpp (ROOT-10731) and
59+
# test03_arraydatamember_lifeline (#7501) were removed: they are covered
60+
# upstream by cppyy's test_lowlevel.py::test09_numpy_bool_array and
61+
# test_datatypes.py::test44_buffer_memory_handling respectively.
9262

9363

9464
## actual test run

roottest/python/basic/ReturnValues.C

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)