This is an automated email from the ASF dual-hosted git repository.

skm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 30f6c39  [MXNET-696] Simplify the logic behind the reload(mxnet) test 
(#12188)
30f6c39 is described below

commit 30f6c39ba6080390da6e30b9fb83f8913a3e4885
Author: cclauss <[email protected]>
AuthorDate: Fri Aug 17 17:39:08 2018 +0200

    [MXNET-696] Simplify the logic behind the reload(mxnet) test (#12188)
    
    * Simplify the logic behind the reload(mxnet) test
    
    * Force a retest
    
    * Remove trailing whitespace
---
 tests/python/unittest/test_engine_import.py | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/tests/python/unittest/test_engine_import.py 
b/tests/python/unittest/test_engine_import.py
index 7395e7e..303f3ce 100644
--- a/tests/python/unittest/test_engine_import.py
+++ b/tests/python/unittest/test_engine_import.py
@@ -16,29 +16,24 @@
 # under the License.
 
 import os
-import sys
+
+try:
+    reload         # Python 2
+except NameError:  # Python 3
+    from importlib import reload
 
 
 def test_engine_import():
     import mxnet
-    def test_import():
-        version = sys.version_info
-        if version >= (3, 4):
-            import importlib
-            importlib.reload(mxnet)
-        elif version >= (3, ):
-            import imp
-            imp.reload(mxnet)
-        else:
-            reload(mxnet)
+        
     engine_types = ['', 'NaiveEngine', 'ThreadedEngine', 
'ThreadedEnginePerDevice']
 
     for type in engine_types:
-        if not type:
-            os.environ.pop('MXNET_ENGINE_TYPE', None)
-        else:
+        if type:
             os.environ['MXNET_ENGINE_TYPE'] = type
-        test_import()
+        else:
+            os.environ.pop('MXNET_ENGINE_TYPE', None)
+        reload(mxnet)
 
 
 if __name__ == '__main__':

Reply via email to