[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Testing failed for higher python3 versions



commit 9df8c1214b572431b2ea08681931f6dcaa6dac05
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun May 28 14:49:25 2017 -0700

    Testing failed for higher python3 versions
    
    When testing with python 3.6 our tests fail to run at all with...
    
      module 'unittest' has no attribute '__version__'
    
    With python 3.2 __import__ worked as we expected but in 3.6 running
    "__import__('unittest.mock')" provides the top unittest module rather than
    mock.
    
    Turns out the __import__ help info asks callers to never use it, and use
    importlib instead. Swapping over fixes this, and is still compatible with
    python 2.7.
---
 test/task.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/test/task.py b/test/task.py
index 048eade..cff4c72 100644
--- a/test/task.py
+++ b/test/task.py
@@ -21,6 +21,7 @@
   +- PYCODESTYLE_TASK - style checks
 """
 
+import importlib
 import os
 import re
 import sys
@@ -199,7 +200,7 @@ class ModuleVersion(Task):
       if prereq_check is None or prereq_check():
         for module in modules:
           if stem.util.test_tools._module_exists(module):
-            return __import__(module).__version__
+            return importlib.import_module(module).__version__
 
       return 'missing'
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits