Skip to contentSkip to conversation

oeqa/core/loader.py: Do not import underscore modules by default

PATCH Superseded [email protected] 2 participants 2 messages Mar 27, 2017 1 message not in the archive

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 oeqa/core/loader.py: Do not import underscore modules by default

From: Mariano Lopez <[email protected]>

Underscore modules are meant to be run only when manually added to the test suite, so far another mechanisms are in place to make this happen with runtime, sdk, and esdk (mostly in test* bbclasses).

This will add such functionality in the core framework so other specific frameworks can take use this without adding something else.

[YOCTO 10980]

---
 meta/lib/oeqa/core/loader.py | 34 ++++++++++++++++++++++++++++++----
 1 file changed, 30 insertions(+), 4 deletions(-)
meta/lib/oeqa/core/loader.py +30 -4
index 74f1117..63a1703 100644
@@ -223,8 +223,21 @@ class OETestLoader(unittest.TestLoader):
                 msg = 'Tried to import %s test module but is a built-in'
                 raise ImportError(msg % module.__name__)
 
-            if not self.modules or "all" in self.modules or \
-                    module.__name__ in self.modules:
+            # Normal test modules are loaded if no modules were specified,
+            # if module is in the specified module list or if 'all' is in
+            # module list.
+            # Underscore modules are loaded only if specified in module list.
+            load_module = True if not module.__name__.startswith('_') \
+                                  and (not self.modules \
+                                       or module.__name__ in self.modules \
+                                       or 'all' in self.modules) \
+                               else False
+
+            load_underscore = True if module.__name__.startswith('_') \
+                                      and module.__name__ in self.modules \
+                                   else False
+
+            if load_module or load_underscore:
                 return super(OETestLoader, self).loadTestsFromModule(
                         module, *args, pattern=pattern, **kws)
             else:
@@ -238,8 +251,21 @@ class OETestLoader(unittest.TestLoader):
                 msg = 'Tried to import %s test module but is a built-in'
                 raise ImportError(msg % module.__name__)
 
-            if not self.modules or "all" in self.modules or \
-                    module.__name__ in self.modules:
+            # Normal test modules are loaded if no modules were specified,
+            # if module is in the specified module list or if 'all' is in
+            # module list.
+            # Underscore modules are loaded only if specified in module list.
+            load_module = True if not module.__name__.startswith('_') \
+                                  and (not self.modules \
+                                       or module.__name__ in self.modules \
+                                       or 'all' in self.modules) \
+                               else False
+
+            load_underscore = True if module.__name__.startswith('_') \
+                                      and module.__name__ in self.modules \
+                                   else False
+
+            if load_module or load_underscore:
                 return super(OETestLoader, self).loadTestsFromModule(
                         module, use_load_tests)
             else:
Signature · 1 line
2.10.2
#2 lore raw

✗ patchtest: failure for oeqa/core/loader.py: Do not import underscore modules by default

In reply to a message not in the archive

== Series Details ==

Series: oeqa/core/loader.py: Do not import underscore modules by default
Revision: 1
URL : https://patchwork.openembedded.org/series/6002/
State : failure

== Summary ==

Thank you for submitting this patch series to OpenEmbedded Core. This is an automated response. Several tests have been executed on the proposed series by patchtest resulting in the following failures:

* Patch            [1/1] oeqa/core/loader.py: Do not import underscore modules by default
 Issue             Yocto Project bugzilla tag is not correctly formatted [test_bugzilla_entry_format] 
  Suggested fix    Specify bugzilla ID in commit description with format: "[YOCTO #<bugzilla ID>]"

If you believe any of these test results are incorrect, please reply to the mailing list ([email protected]) raising your concerns. Otherwise we would appreciate you correcting the issues and submitting a new version of the patchset if applicable. Please ensure you add/increment the version number when sending the new version (i.e. [PATCH] -> [PATCH v2] -> [PATCH v3] -> ...).

---

Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe