[master 1/1] Remove facilities for running tests as standalone modules.

mulkieran installerbot-noreply at redhat.com
Thu Jun 4 13:07:06 UTC 2015


From: Alexander Todorov <atodorov at redhat.com>

* Remove #!/usr/bin/python shebang from tests.
* Remove unittest.main() from tests.
* Remove a definition of suite method, which we no longer use.

The tests should be run via the unittest discovery mechanism.
They are best run by invoking the "test" target in the Makefile.

This allows any necessary setup to occur, including overrides
for Python2/3 compatibility.

Signed-off-by: mulhern <amulhern at redhat.com>
---
 tests/action_test.py                         | 5 -----
 tests/devicefactory_test.py                  | 4 ----
 tests/devicelibs_test/mdraid_test.py         | 4 ----
 tests/devicelibs_test/raid_test.py           | 1 -
 tests/devices_test/dependencies_test.py      | 4 ----
 tests/devices_test/device_names_test.py      | 4 ----
 tests/devices_test/device_packages_test.py   | 4 ----
 tests/devices_test/device_properties_test.py | 4 ----
 tests/devices_test/lvm_test.py               | 4 ----
 tests/devices_test/network_test.py           | 4 ----
 tests/devices_test/partition_test.py         | 4 ----
 tests/devicetree_test.py                     | 3 ---
 tests/formats_test/device_test.py            | 4 ----
 tests/formats_test/fs_test.py                | 4 ----
 tests/formats_test/fslabeling.py             | 1 -
 tests/formats_test/fstesting.py              | 1 -
 tests/formats_test/init_test.py              | 1 -
 tests/formats_test/labeling_test.py          | 4 ----
 tests/formats_test/selinux_test.py           | 4 ----
 tests/parentlist_test.py                     | 9 ---------
 tests/partitioning_test.py                   | 4 ----
 tests/size_test.py                           | 4 ----
 tests/storagetestcase.py                     | 1 -
 tests/tasks_test/basic_tests.py              | 1 -
 tests/tsort_test.py                          | 3 ---
 tests/udev_test.py                           | 5 -----
 tests/util_test.py                           | 1 -
 27 files changed, 92 deletions(-)
 mode change 100755 => 100644 tests/devicelibs_test/mdraid_test.py
 mode change 100755 => 100644 tests/formats_test/device_test.py
 mode change 100755 => 100644 tests/formats_test/fs_test.py
 mode change 100755 => 100644 tests/formats_test/labeling_test.py
 mode change 100755 => 100644 tests/formats_test/selinux_test.py

diff --git a/tests/action_test.py b/tests/action_test.py
index 3cb9349..b77529a 100644
--- a/tests/action_test.py
+++ b/tests/action_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 
 import unittest
 
@@ -1162,7 +1161,3 @@ def testContainerActions(self):
     def testActionSorting(self, *args, **kwargs):
         """ Verify correct functioning of action sorting. """
         pass
-
-if __name__ == "__main__":
-    unittest.main()
-
diff --git a/tests/devicefactory_test.py b/tests/devicefactory_test.py
index 8ea43cb..6d13e2e 100644
--- a/tests/devicefactory_test.py
+++ b/tests/devicefactory_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 
 import unittest
 
@@ -58,6 +57,3 @@ def testMDFactory(self):
         self.assertEqual(self.factory2.container_list, [])
 
         self.assertIsNone(self.factory2.get_container())
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/devicelibs_test/mdraid_test.py b/tests/devicelibs_test/mdraid_test.py
old mode 100755
new mode 100644
index 6408f03..56c2ed1
--- a/tests/devicelibs_test/mdraid_test.py
+++ b/tests/devicelibs_test/mdraid_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 import unittest
 
 import blivet.devicelibs.mdraid as mdraid
@@ -16,6 +15,3 @@ def testMDRaid(self):
         self.assertEqual(mdraid.RAID_levels.raidLevel(5).name, "raid5")
         self.assertEqual(mdraid.RAID_levels.raidLevel("RAID6").name, "raid6")
         self.assertEqual(mdraid.RAID_levels.raidLevel("raid10").name, "raid10")
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/devicelibs_test/raid_test.py b/tests/devicelibs_test/raid_test.py
index ba1a580..9d0105a 100644
--- a/tests/devicelibs_test/raid_test.py
+++ b/tests/devicelibs_test/raid_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 import unittest
 
 import blivet.devicelibs.raid as raid
diff --git a/tests/devices_test/dependencies_test.py b/tests/devices_test/dependencies_test.py
index 55ea3de..78d3416 100644
--- a/tests/devices_test/dependencies_test.py
+++ b/tests/devices_test/dependencies_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # vim:set fileencoding=utf-8
 
 import unittest
@@ -85,6 +84,3 @@ def tearDown(self):
         availability.BLOCKDEV_DM_PLUGIN.available # pylint: disable=pointless-statement
 
         availability.CACHE_AVAILABILITY = self.cache_availability
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/devices_test/device_names_test.py b/tests/devices_test/device_names_test.py
index f15f471..3e91343 100644
--- a/tests/devices_test/device_names_test.py
+++ b/tests/devices_test/device_names_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # vim:set fileencoding=utf-8
 
 import unittest
@@ -41,6 +40,3 @@ def testLogicalVolume(self):
 
         for name in bad_names:
             self.assertFalse(LVMLogicalVolumeDevice.isNameValid(name))
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/devices_test/device_packages_test.py b/tests/devices_test/device_packages_test.py
index a3295f5..3e3863f 100644
--- a/tests/devices_test/device_packages_test.py
+++ b/tests/devices_test/device_packages_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # vim:set fileencoding=utf-8
 
 import unittest
@@ -29,6 +28,3 @@ def testPackages(self):
 
         for package in dev1.format.packages + dev2.format.packages + dev.format.packages:
             self.assertIn(package, packages)
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/devices_test/device_properties_test.py b/tests/devices_test/device_properties_test.py
index 8330c2d..6b93e53 100644
--- a/tests/devices_test/device_properties_test.py
+++ b/tests/devices_test/device_properties_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # vim:set fileencoding=utf-8
 
 import unittest
@@ -709,6 +708,3 @@ def testBTRFSSnapShotDeviceInit(self):
 
         self.assertEqual(snap.dependsOn(vol), True)
         self.assertEqual(vol.dependsOn(snap), False)
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/devices_test/lvm_test.py b/tests/devices_test/lvm_test.py
index 72fbd83..e952fc6 100644
--- a/tests/devices_test/lvm_test.py
+++ b/tests/devices_test/lvm_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # vim:set fileencoding=utf-8
 
 import unittest
@@ -137,6 +136,3 @@ def testTargetSize(self):
         lv.targetSize = orig_size
         self.assertEqual(lv.targetSize, orig_size)
         self.assertEqual(lv.size, orig_size)
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/devices_test/network_test.py b/tests/devices_test/network_test.py
index 8a954fc..564390a 100644
--- a/tests/devices_test/network_test.py
+++ b/tests/devices_test/network_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # vim:set fileencoding=utf-8
 
 import unittest
@@ -35,6 +34,3 @@ def testNetDevUpdate(self):
         dev.create()
 
         self.assertTrue("_netdev" in dev.format.options.split(","))
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/devices_test/partition_test.py b/tests/devices_test/partition_test.py
index b4fef6c..bf65157 100644
--- a/tests/devices_test/partition_test.py
+++ b/tests/devices_test/partition_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # vim:set fileencoding=utf-8
 
 import os
@@ -155,6 +154,3 @@ def testMinMaxSizeAlignment(self):
             self.assertEqual(
                 disk.format.endAlignment.isAligned(free, max_end_sector),
                 True)
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/devicetree_test.py b/tests/devicetree_test.py
index 906fe7a..2d5c6ae 100644
--- a/tests/devicetree_test.py
+++ b/tests/devicetree_test.py
@@ -278,6 +278,3 @@ def _set_up_storage(self):
                                   None,
                                   disks=self.blivet.disks[:],
                                   container_raid_level="raid1")
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/formats_test/device_test.py b/tests/formats_test/device_test.py
old mode 100755
new mode 100644
index 588cb97..ea58640
--- a/tests/formats_test/device_test.py
+++ b/tests/formats_test/device_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 import unittest
 
 import blivet
@@ -78,6 +77,3 @@ def testValue(self):
                 an_fs.device = "/abc:/def"
                 self.assertEqual(an_fs.type, typ)
                 self.assertEqual(an_fs.device, "/abc:/def")
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/formats_test/fs_test.py b/tests/formats_test/fs_test.py
old mode 100755
new mode 100644
index 71fa524..70216d3
--- a/tests/formats_test/fs_test.py
+++ b/tests/formats_test/fs_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 import os
 import tempfile
 import unittest
@@ -139,6 +138,3 @@ def tearDown(self):
         except Exception: # pylint: disable=broad-except
             pass
         os.rmdir(self.mountpoint)
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/formats_test/fslabeling.py b/tests/formats_test/fslabeling.py
index 200cffe..fc63210 100644
--- a/tests/formats_test/fslabeling.py
+++ b/tests/formats_test/fslabeling.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 
 import abc
 from six import add_metaclass
diff --git a/tests/formats_test/fstesting.py b/tests/formats_test/fstesting.py
index dad6e3f..377ebff 100644
--- a/tests/formats_test/fstesting.py
+++ b/tests/formats_test/fstesting.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 
 import abc
 from six import add_metaclass
diff --git a/tests/formats_test/init_test.py b/tests/formats_test/init_test.py
index 6fc11c6..d877094 100644
--- a/tests/formats_test/init_test.py
+++ b/tests/formats_test/init_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 import copy
 import unittest
 
diff --git a/tests/formats_test/labeling_test.py b/tests/formats_test/labeling_test.py
old mode 100755
new mode 100644
index 6d167f1..2f53a92
--- a/tests/formats_test/labeling_test.py
+++ b/tests/formats_test/labeling_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 import unittest
 
 from tests import loopbackedtestcase
@@ -103,6 +102,3 @@ def testCreatingSwapSpaceNone(self):
     def testCreatingSwapSpaceEmpty(self):
         swp = swap.SwapSpace(device=self.loopDevices[0], label="")
         self.assertIsNone(swp.create())
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/formats_test/selinux_test.py b/tests/formats_test/selinux_test.py
old mode 100755
new mode 100644
index b5c62eb..44fe220
--- a/tests/formats_test/selinux_test.py
+++ b/tests/formats_test/selinux_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 import os
 import selinux
 import tempfile
@@ -94,6 +93,3 @@ def testMountingXFS(self):
     def tearDown(self):
         super(SELinuxContextTestCase, self).tearDown()
         blivet.flags.installer_mode = self.installer_mode
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/parentlist_test.py b/tests/parentlist_test.py
index bce13a0..b4295be 100644
--- a/tests/parentlist_test.py
+++ b/tests/parentlist_test.py
@@ -76,12 +76,3 @@ def testDeviceParents(self):
 
         dev3.parents = []
         self.assertEqual(len(dev3.parents), 0)
-
-
-def suite():
-    return unittest.TestLoader().loadTestsFromTestCase(ParentListTestCase)
-
-
-if __name__ == "__main__":
-    unittest.main()
-
diff --git a/tests/partitioning_test.py b/tests/partitioning_test.py
index 0a301bc..c633bbe 100644
--- a/tests/partitioning_test.py
+++ b/tests/partitioning_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 
 import unittest
 from mock import Mock
@@ -586,6 +585,3 @@ def testExplicitExtendedPartitions(self):
                          "user-specified extended partition was removed")
 
         self.blivet.doIt()
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/size_test.py b/tests/size_test.py
index 0556099..132bfd0 100644
--- a/tests/size_test.py
+++ b/tests/size_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 # pylint: disable=environment-modify
 #
 # tests/storage/size_tests.py
@@ -449,6 +448,3 @@ def testArithmetic(self):
         self.assertIsInstance(2/s, Decimal)
         self.assertIsInstance(2**Size(2), Decimal)
         self.assertIsInstance(1024 % Size(127), Decimal)
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/storagetestcase.py b/tests/storagetestcase.py
index ad1216f..7ac48d3 100644
--- a/tests/storagetestcase.py
+++ b/tests/storagetestcase.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 
 import unittest
 from mock import Mock
diff --git a/tests/tasks_test/basic_tests.py b/tests/tasks_test/basic_tests.py
index 3565b03..3814973 100644
--- a/tests/tasks_test/basic_tests.py
+++ b/tests/tasks_test/basic_tests.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 import unittest
 
 import blivet.tasks.task as task
diff --git a/tests/tsort_test.py b/tests/tsort_test.py
index 640becd..7de0633 100644
--- a/tests/tsort_test.py
+++ b/tests/tsort_test.py
@@ -51,6 +51,3 @@ def check_order(order, graph):
         # verify that all ordering constraints are satisfied
         self.failUnless(check_order(order, graph),
                         "ordering constraints not satisfied")
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/udev_test.py b/tests/udev_test.py
index e3e817d..dff8c1b 100644
--- a/tests/udev_test.py
+++ b/tests/udev_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 
 import unittest
 import mock
@@ -35,7 +34,3 @@ def udev_trigger_test(self):
         import blivet.udev
         blivet.udev.trigger()
         self.assertTrue(blivet.udev.util.run_program.called)
-
-
-if __name__ == "__main__":
-    unittest.main()
diff --git a/tests/util_test.py b/tests/util_test.py
index 6f3a02e..e47e252 100644
--- a/tests/util_test.py
+++ b/tests/util_test.py
@@ -1,4 +1,3 @@
-#!/usr/bin/python
 
 import unittest
 from decimal import Decimal


-- 
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/7c0aca6e74da1e2b74fd10f559b89bfa68ee2be0


More information about the anaconda-patches mailing list