diff --git a/test/test_moduleLoad.py b/test/test_moduleLoad.py index 6c0486a7..561ec35a 100644 --- a/test/test_moduleLoad.py +++ b/test/test_moduleLoad.py @@ -38,6 +38,15 @@ def test__dbConfig(self): def test_BlockUseSwsssdk(): # Import swsssdk will throw exception with deprecated message. swsssdk_path = os.path.join(modules_path, 'src') - result = subprocess.run(["python", "-c", "import swsssdk;exit()"], capture_output=True, cwd=swsssdk_path) + result = None + python_command = "python" + + if sys.version_info.major == 3: + python_command = "python3" - assert "deprecated" in result.stderr.decode("utf-8") + try: + subprocess.check_output([python_command, "-c", "import swsssdk;exit()"], stderr=subprocess.STDOUT, cwd=swsssdk_path) + except subprocess.CalledProcessError as e: + result = e.output.decode("utf-8") + + assert "deprecated" in result