From caedff0f1e5398590a65417f38694c7f847dcbc3 Mon Sep 17 00:00:00 2001 From: sever-sever Date: Thu, 3 Dec 2020 19:03:42 +0000 Subject: smoketest: T3108: Fix regex for count pattern Config --- smoketest/scripts/cli/test_configd_inspect.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/smoketest/scripts/cli/test_configd_inspect.py b/smoketest/scripts/cli/test_configd_inspect.py index 5181187e9..4ebee8cc5 100755 --- a/smoketest/scripts/cli/test_configd_inspect.py +++ b/smoketest/scripts/cli/test_configd_inspect.py @@ -15,6 +15,7 @@ # along with this program. If not, see . import os +import re import json import unittest import warnings @@ -78,7 +79,8 @@ class TestConfigdInclude(unittest.TestCase): if not f: continue str_f = getsource(f) - n = str_f.count('Config()') + # Regex not XXXConfig() T3108 + n = len(re.findall(r'[^a-zA-Z]Config\(\)', str_f)) if i == 'get_config': self.assertEqual(n, 1, f"'{s}': '{i}' no instance of Config") @@ -91,7 +93,8 @@ class TestConfigdInclude(unittest.TestCase): for s in self.inc_list: m = import_script(s) str_m = getsource(m) - n = str_m.count('Config()') + # Regex not XXXConfig T3108 + n = len(re.findall(r'[^a-zA-Z]Config\(\)', str_m)) self.assertEqual(n, 1, f"'{s}' more than one instance of Config") -- cgit v1.2.3