Salome HOME
style: black format
[tools/sat.git] / test / test_sat5_0 / prepare / test_patch.py
index 1dc24d43dfb29f6fb0de06bf8ba56f246bb7af64..af7a375ee9ccbaba8148aff3f368d5835779216c 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-#-*- coding:utf-8 -*-
+# -*- coding:utf-8 -*-
 
 #  Copyright (C) 2010-2018  CEA/DEN
 #
@@ -26,142 +26,151 @@ from src.salomeTools import Sat
 import src.product
 from unittestpy.tools import outRedirection
 
+
 class TestCase(unittest.TestCase):
     """Test of the patch command"""
 
     def test_010(self):
         # Test the patch command with a product in dev mode
-        OK = 'KO'
+        OK = "KO"
 
-        appli = 'appli-test'
-        product_name = 'PRODUCT_DEV'
+        appli = "appli-test"
+        product_name = "PRODUCT_DEV"
 
         sat = Sat("-oUSER.output_level=2")
-               
+
         sat.config(appli)
-        
-        expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
-        expected_file_path = os.path.join(expected_src_dir, 'my_test_file.txt')
-        expected_text = 'HELLO WORLD\n'
-        
+
+        expected_src_dir = src.product.get_product_config(
+            sat.cfg, product_name
+        ).source_dir
+        expected_file_path = os.path.join(expected_src_dir, "my_test_file.txt")
+        expected_text = "HELLO WORLD\n"
+
         if os.path.exists(expected_src_dir):
             shutil.rmtree(expected_src_dir)
-        
-        sat.source(appli + ' --product ' + product_name)
-        
-        f = open(expected_file_path, 'r')
+
+        sat.source(appli + " --product " + product_name)
+
+        f = open(expected_file_path, "r")
         text = f.readlines()[0]
-        OK1 = 'KO'
+        OK1 = "KO"
         if text == expected_text:
-            OK1 = 'OK'
-       
-        sat.patch(appli + ' --product ' + product_name)
-        
-        new_expected_text = 'HELLO WORLD MODIFIED\n'
-        f = open(expected_file_path, 'r')
+            OK1 = "OK"
+
+        sat.patch(appli + " --product " + product_name)
+
+        new_expected_text = "HELLO WORLD MODIFIED\n"
+        f = open(expected_file_path, "r")
         text = f.readlines()[0]
-        
-        OK2 = 'KO'
+
+        OK2 = "KO"
         if text == new_expected_text:
-            OK2 = 'OK'         
+            OK2 = "OK"
 
-        if (OK1, OK2)==('OK', 'OK'):
-            OK = 'OK'
-        self.assertEqual(OK, 'OK')
+        if (OK1, OK2) == ("OK", "OK"):
+            OK = "OK"
+        self.assertEqual(OK, "OK")
 
     def test_020(self):
         # Test the patch command with a product with no sources found
-        OK = 'KO'
+        OK = "KO"
 
-        appli = 'appli-test'
-        product_name = 'PRODUCT_DEV'
+        appli = "appli-test"
+        product_name = "PRODUCT_DEV"
 
-        sat = Sat('')
+        sat = Sat("")
         sat.config(appli)
-        
-        expected_src_dir = src.product.get_product_config(sat.cfg, product_name).source_dir
-        
+
+        expected_src_dir = src.product.get_product_config(
+            sat.cfg, product_name
+        ).source_dir
+
         if os.path.exists(expected_src_dir):
             shutil.rmtree(expected_src_dir)
-               
+
         # output redirection
         my_out = outRedirection()
-        
-        sat.patch(appli + ' --product ' + product_name)
-        
+
+        sat.patch(appli + " --product " + product_name)
+
         # stop output redirection
         my_out.end_redirection()
 
         # get results
         res = my_out.read_results()
-        
-        if "No sources found for the " + product_name +" product" in res:
-            OK = 'OK'
-        self.assertEqual(OK, 'OK')
+
+        if "No sources found for the " + product_name + " product" in res:
+            OK = "OK"
+        self.assertEqual(OK, "OK")
 
     def test_030(self):
         # Test the patch command with a product without patch
-        OK = 'KO'
+        OK = "KO"
+
+        appli = "appli-test"
+        product_name = "PRODUCT_ARCHIVE"
 
-        appli = 'appli-test'
-        product_name = 'PRODUCT_ARCHIVE'
+        sat = Sat("-v4")
+
+        sat.source(appli + " --product " + product_name)
 
-        sat = Sat('-v4')
-                      
-        sat.source(appli + ' --product ' + product_name)
-               
         # output redirection
         my_out = outRedirection()
-        
-        sat.patch(appli + ' --product ' + product_name)
-        
+
+        sat.patch(appli + " --product " + product_name)
+
         # stop output redirection
         my_out.end_redirection()
 
         # get results
         res = my_out.read_results()
-        
-        if "No patch for the " + product_name +" product" in res:
-            OK = 'OK'
-        self.assertEqual(OK, 'OK')
+
+        if "No patch for the " + product_name + " product" in res:
+            OK = "OK"
+        self.assertEqual(OK, "OK")
 
     def test_040(self):
         # Test the patch command with a product with a not valid patch
-        OK = 'KO'
+        OK = "KO"
 
-        appli = 'appli-test'
-        product_name = 'PRODUCT_DEV'
+        appli = "appli-test"
+        product_name = "PRODUCT_DEV"
 
         sat = Sat("-oPRODUCTS.PRODUCT_DEV.default.patches=['/']")
-                      
-        sat.source(appli + ' --product ' + product_name)
-               
+
+        sat.source(appli + " --product " + product_name)
+
         # output redirection
         my_out = outRedirection()
-        
-        sat.patch(appli + ' --product ' + product_name)
-        
+
+        sat.patch(appli + " --product " + product_name)
+
         # stop output redirection
         my_out.end_redirection()
 
         # get results
         res = my_out.read_results()
-        
+
         if "Not a valid patch" in res:
-            OK = 'OK'
-        self.assertEqual(OK, 'OK')
+            OK = "OK"
+        self.assertEqual(OK, "OK")
 
     def test_050(self):
         # Test the sat -h patch
         OK = "KO"
 
         import patch
-        
-        if "The patch command apply the patches on the sources of" in patch.description():
+
+        if (
+            "The patch command apply the patches on the sources of"
+            in patch.description()
+        ):
             OK = "OK"
         self.assertEqual(OK, "OK")
 
+
 # test launch
-if __name__ == '__main__':
+if __name__ == "__main__":
     unittest.main()
     pass