From 50ae786d5bbac467b3f48e0415bbb8728e75a55b Mon Sep 17 00:00:00 2001 From: Sebastien Ponce <sebastien.ponce@cern.ch> Date: Thu, 17 Nov 2022 16:55:18 +0100 Subject: [PATCH 1/2] fixed tests which depend on unique names --- Phys/FunctorCore/python/Functors/__init__.py | 8 ++++---- Pr/PrConverters/tests/qmtest/convert_vertices.qmt | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Phys/FunctorCore/python/Functors/__init__.py b/Phys/FunctorCore/python/Functors/__init__.py index 34ef54af103..baf1312752a 100644 --- a/Phys/FunctorCore/python/Functors/__init__.py +++ b/Phys/FunctorCore/python/Functors/__init__.py @@ -706,9 +706,9 @@ def SHARE_BPV(Vertices: DataHandle): >>> import Functors as F >>> from Functors.tests.categories import dummy_data_particle_range, dummy_data_pv_container >>> from PyConf.Algorithms import WeightedRelTableAlg - >>> alg = WeightedRelTableAlg(InputCandidates = dummy_data_particle_range, ReferenceParticles = dummy_data_particle_range, Cut = F.SHARE_BPV(dummy_data_pv_container) ) + >>> alg = WeightedRelTableAlg(name="WeightedRelTableAlg_SHARE_BPV", InputCandidates = dummy_data_particle_range, ReferenceParticles = dummy_data_particle_range, Cut = F.SHARE_BPV(dummy_data_pv_container) ) >>> alg.OutputRelations - DataHandle('/Event/WeightedRelTableAlg#1/OutputRelations') + DataHandle('/Event/WeightedRelTableAlg_SHARE_BPV/OutputRelations') """ return ADDRESSOF @ BPV(Vertices) @ FORWARDARG0 == ADDRESSOF @ BPV( Vertices) @ FORWARDARG1 @@ -2189,9 +2189,9 @@ def RPPVIPCHI2(Vertices: DataHandle): >>> import Functors as F >>> from PyConf.Algorithms import WeightedRelTableAlg >>> from Functors.tests.categories import dummy_data_particle_range, dummy_data_pv_container - >>> alg = WeightedRelTableAlg(InputCandidates = dummy_data_particle_range, ReferenceParticles = dummy_data_particle_range, Cut = F.RPPVIPCHI2(dummy_data_pv_container) > 12) + >>> alg = WeightedRelTableAlg(name="WeightedRelTableAlg_RPPVIPCHI2", InputCandidates = dummy_data_particle_range, ReferenceParticles = dummy_data_particle_range, Cut = F.RPPVIPCHI2(dummy_data_pv_container) > 12) >>> alg.OutputRelations - DataHandle('/Event/WeightedRelTableAlg/OutputRelations') + DataHandle('/Event/WeightedRelTableAlg_RPPVIPCHI2/OutputRelations') """ ref_part_pv = BPV(Vertices) @ FORWARDARG0 return IPCHI2.bind(ref_part_pv, FORWARDARG1) diff --git a/Pr/PrConverters/tests/qmtest/convert_vertices.qmt b/Pr/PrConverters/tests/qmtest/convert_vertices.qmt index 5dc326b51bd..ded6cc899e2 100644 --- a/Pr/PrConverters/tests/qmtest/convert_vertices.qmt +++ b/Pr/PrConverters/tests/qmtest/convert_vertices.qmt @@ -26,6 +26,7 @@ A counter-based internal consistenty test of vertex converters. # that for the initial PatPV3DFuture construction. from GaudiConf.QMTest.LHCbTest import extract_counters +from PyConf.components import findCounters ctrs = extract_counters(stdout) @@ -34,13 +35,14 @@ v1_keys = ['LHCb__Converters__RecVertex__v1_...', 'Nb of converted Vertices'] v2_keys = ['LHCb__Converters__RecVertex__v2_...', 'Nb of converted Vertices'] nvs_0 = -1 -if init_keys[0] in ctrs: - if init_keys[1] in ctrs[init_keys[0]]: - nvs_0 = int(ctrs[init_keys[0]][init_keys[1]][1]) +try: + cs = findCounters(ctrs, init_keys[0]) + if init_keys[1] in cs: + nvs_0 = int(cs[init_keys[1]][1]) else: causes.append('expected counters called "{}" for {}'.format( init_keys[1], init_keys[0])) -else: +except Exception: causes.append('expected counters for ' + init_keys[0]) if v1_keys[0] in ctrs: -- GitLab From 4272d2e5bb7e3d419752fa1ed699a4e1a37388e6 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce <sebastien.ponce@cern.ch> Date: Tue, 21 Feb 2023 15:37:09 +0100 Subject: [PATCH 2/2] Remove duplicated testing. doctest is already used by the standard pytest --- .../python/Functors/tests/test_pyconf.py | 14 ----------- Phys/FunctorCore/tests/qmtest/test_pyconf.qmt | 25 ------------------- 2 files changed, 39 deletions(-) delete mode 100644 Phys/FunctorCore/tests/qmtest/test_pyconf.qmt diff --git a/Phys/FunctorCore/python/Functors/tests/test_pyconf.py b/Phys/FunctorCore/python/Functors/tests/test_pyconf.py index 0a7d0d31bba..b5d19f76a67 100644 --- a/Phys/FunctorCore/python/Functors/tests/test_pyconf.py +++ b/Phys/FunctorCore/python/Functors/tests/test_pyconf.py @@ -87,17 +87,3 @@ def test_string_datahandle_exception(caplog): # Use the DataHandle's concrete string location raises an exception with pytest.raises(TypeError, match=".*only accepts DataHandle.*"): TES(pvs.location) - - -def test_doctests(): - """ - Check the doctests for all functions in the same modules - of those listed in funcs - """ - #Just pick an functor as example - funcs = [TES, log] - for func in funcs: - module = inspect.getmodule(func) - globs = {func.__name__: module} - result = doctest.testmod(module, globs=globs) - assert result.failed == 0 diff --git a/Phys/FunctorCore/tests/qmtest/test_pyconf.qmt b/Phys/FunctorCore/tests/qmtest/test_pyconf.qmt deleted file mode 100644 index 9b3bfe6319f..00000000000 --- a/Phys/FunctorCore/tests/qmtest/test_pyconf.qmt +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" ?><!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'> -<!-- - (c) Copyright 2023 CERN for the benefit of the LHCb Collaboration - - This software is distributed under the terms of the GNU General Public - Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". - - In applying this licence, CERN does not waive the privileges and immunities - granted to it by virtue of its status as an Intergovernmental Organization - or submit itself to any jurisdiction. ---> -<!-- -####################################################### -# SUMMARY OF THIS TEST -# ................... -# Authors: tfulghes -# Purpose: Add pyconf tests -####################################################### ---> -<extension class="GaudiTest.GaudiExeTest" kind="test"> - <argument name="program"><text>pytest</text></argument> - <argument name="args"><set> - <text>../../python/Functors/tests/test_pyconf.py</text> - </set></argument> -</extension> -- GitLab