JDevlieghere created this revision.
JDevlieghere added reviewers: labath, clayborg, lanza.
Herald added a project: All.
JDevlieghere requested review of this revision.
Herald added a project: LLDB.

Remove Python 2 checks from the test suite


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124430

Files:
  lldb/test/API/functionalities/step_scripted/TestStepScripted.py
  lldb/test/API/lldbtest.py
  lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py
  lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py
  lldb/test/API/python_api/file_handle/TestFileHandle.py
  lldb/test/API/terminal/TestSTTYBeforeAndAfter.py

Index: lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
===================================================================
--- lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
+++ lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
@@ -7,6 +7,7 @@
 
 import lldb
 import six
+import sys
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
@@ -41,11 +42,7 @@
         lldb_prompt = "(lldb) "
 
         # So that the child gets torn down after the test.
-        import sys
-        if sys.version_info.major == 3:
-          self.child = pexpect.spawnu('expect')
-        else:
-          self.child = pexpect.spawn('expect')
+        self.child = pexpect.spawnu('expect')
         child = self.child
 
         child.expect(expect_prompt)
Index: lldb/test/API/python_api/file_handle/TestFileHandle.py
===================================================================
--- lldb/test/API/python_api/file_handle/TestFileHandle.py
+++ lldb/test/API/python_api/file_handle/TestFileHandle.py
@@ -605,18 +605,15 @@
     def test_exceptions(self):
         self.assertRaises(Exception, lldb.SBFile, None)
         self.assertRaises(Exception, lldb.SBFile, "ham sandwich")
-        if sys.version_info[0] < 3:
-            self.assertRaises(Exception, lldb.SBFile, ReallyBadIO())
-        else:
-            self.assertRaises(OhNoe, lldb.SBFile, ReallyBadIO())
-            error, n = lldb.SBFile(BadIO()).Write(b"FOO")
-            self.assertEqual(n, 0)
-            self.assertTrue(error.Fail())
-            self.assertIn('OH NOE', error.GetCString())
-            error, n = lldb.SBFile(BadIO()).Read(bytearray(100))
-            self.assertEqual(n, 0)
-            self.assertTrue(error.Fail())
-            self.assertIn('OH NOE', error.GetCString())
+        self.assertRaises(OhNoe, lldb.SBFile, ReallyBadIO())
+        error, n = lldb.SBFile(BadIO()).Write(b"FOO")
+        self.assertEqual(n, 0)
+        self.assertTrue(error.Fail())
+        self.assertIn('OH NOE', error.GetCString())
+        error, n = lldb.SBFile(BadIO()).Read(bytearray(100))
+        self.assertEqual(n, 0)
+        self.assertTrue(error.Fail())
+        self.assertIn('OH NOE', error.GetCString())
 
 
     @skipIf(py_version=['<', (3,)])
Index: lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py
===================================================================
--- lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py
+++ lldb/test/API/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py
@@ -49,19 +49,17 @@
             for i in insts:
                 print("Disassembled %s" % str(i))
 
-        if sys.version_info.major >= 3:
-            sio = StringIO()
-            insts.Print(sio)
-            self.assertEqual(split(assembly), split(sio.getvalue()))
+        sio = StringIO()
+        insts.Print(sio)
+        self.assertEqual(split(assembly), split(sio.getvalue()))
 
         self.assertEqual(insts.GetSize(), len(split(assembly)))
 
-        if sys.version_info.major >= 3:
-            for i,asm in enumerate(split(assembly)):
-                inst = insts.GetInstructionAtIndex(i)
-                sio = StringIO()
-                inst.Print(sio)
-                self.assertEqual(asm, sio.getvalue().strip())
+        for i,asm in enumerate(split(assembly)):
+            inst = insts.GetInstructionAtIndex(i)
+            sio = StringIO()
+            inst.Print(sio)
+            self.assertEqual(asm, sio.getvalue().strip())
 
         raw_bytes = bytearray([0x04, 0xf9, 0xed, 0x82])
 
Index: lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py
===================================================================
--- lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py
+++ lldb/test/API/macosx/nslog/TestDarwinNSLogOutput.py
@@ -10,6 +10,7 @@
 import lldb
 import platform
 import re
+import sys
 
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
@@ -57,13 +58,8 @@
 
         # So that the child gets torn down after the test.
         import pexpect
-        import sys
-        if sys.version_info.major == 3:
-          self.child = pexpect.spawnu('%s %s %s' % (lldbtest_config.lldbExec,
-                                                    self.lldbOption, exe))
-        else:
-          self.child = pexpect.spawn('%s %s %s' % (lldbtest_config.lldbExec,
-                                                   self.lldbOption, exe))
+        self.child = pexpect.spawnu('%s %s %s' % (lldbtest_config.lldbExec,
+                                                  self.lldbOption, exe))
         child = self.child
 
         # Turn on logging for what the child sends back.
Index: lldb/test/API/lldbtest.py
===================================================================
--- lldb/test/API/lldbtest.py
+++ lldb/test/API/lldbtest.py
@@ -74,16 +74,6 @@
             timeoutInfo = 'Reached timeout of {} seconds'.format(
                 litConfig.maxIndividualTestTime)
 
-        if sys.version_info.major == 2:
-            # In Python 2, string objects can contain Unicode characters. Use
-            # the non-strict 'replace' decoding mode. We cannot use the strict
-            # mode right now because lldb's StringPrinter facility and the
-            # Python utf8 decoder have different interpretations of which
-            # characters are "printable". This leads to Python utf8 decoding
-            # exceptions even though lldb is behaving as expected.
-            out = out.decode('utf-8', 'replace')
-            err = err.decode('utf-8', 'replace')
-
         output = """Script:\n--\n%s\n--\nExit Code: %d\n""" % (
             ' '.join(cmd), exitCode)
         if timeoutInfo is not None:
Index: lldb/test/API/functionalities/step_scripted/TestStepScripted.py
===================================================================
--- lldb/test/API/functionalities/step_scripted/TestStepScripted.py
+++ lldb/test/API/functionalities/step_scripted/TestStepScripted.py
@@ -19,13 +19,13 @@
         self.runCmd("command script import Steps.py")
 
     def test_standard_step_out(self):
-        """Tests stepping with the scripted thread plan laying over a standard 
+        """Tests stepping with the scripted thread plan laying over a standard
         thread plan for stepping out."""
         self.build()
         self.step_out_with_scripted_plan("Steps.StepOut")
 
     def test_scripted_step_out(self):
-        """Tests stepping with the scripted thread plan laying over an another 
+        """Tests stepping with the scripted thread plan laying over an another
         scripted thread plan for stepping out."""
         self.build()
         self.step_out_with_scripted_plan("Steps.StepScripted")
@@ -54,23 +54,23 @@
         stop_id = process.GetStopID()
         # Pass a non-existent class for the plan class:
         err = thread.StepUsingScriptedThreadPlan("NoSuchModule.NoSuchPlan")
-        
+
         # Make sure we got a good error:
         self.assertTrue(err.Fail(), "We got a failure state")
         msg = err.GetCString()
         self.assertIn("NoSuchModule.NoSuchPlan", msg, "Mentioned missing class")
-        
+
         # Make sure we didn't let the process run:
         self.assertEqual(stop_id, process.GetStopID(), "Process didn't run")
-        
+
     def test_checking_variable(self):
         """Test that we can call SBValue API's from a scripted thread plan - using SBAPI's to step"""
         self.do_test_checking_variable(False)
-        
+
     def test_checking_variable_cli(self):
         """Test that we can call SBValue API's from a scripted thread plan - using cli to step"""
         self.do_test_checking_variable(True)
-        
+
     def do_test_checking_variable(self, use_cli):
         self.build()
         (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
@@ -101,7 +101,7 @@
 
         # We should not have exited:
         self.assertEqual(process.GetState(), lldb.eStateStopped, "We are stopped")
-        
+
         # We should still be in foo:
         self.assertEqual("foo", frame.GetFunctionName())
 
@@ -127,18 +127,14 @@
         print(Steps.StepReportsStopOthers.stop_mode_dict)
         value = Steps.StepReportsStopOthers.stop_mode_dict[token]
         self.assertEqual(value, stop_others_value, "Stop others has the correct value.")
-        
+
     def do_test_stop_others(self):
         self.build()
         (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
                                                                             "Set a breakpoint here",
                                                                             self.main_source_file)
         # First run with stop others false and see that we got that.
-        thread_id = ""
-        if sys.version_info.major == 2:
-            thread_id = str(threading._get_ident())
-        else:
-            thread_id = str(threading.get_ident())
+        thread_id = str(threading.get_ident())
 
         # all-threads should set stop others to False.
         self.run_step(False, "all-threads", thread_id)
@@ -152,13 +148,8 @@
         # The target.process.run-all-threads should override this:
         interp = self.dbg.GetCommandInterpreter()
         result = lldb.SBCommandReturnObject()
-        
+
         interp.HandleCommand("settings set target.process.run-all-threads true", result)
         self.assertTrue(result.Succeeded, "setting run-all-threads works.")
 
         self.run_step(False, None, thread_id)
-
-        
-        
-
-        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to