Skip to content

Commit

Permalink
Remove facilities for running tests as standalone modules.
Browse files Browse the repository at this point in the history
* 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@redhat.com>
  • Loading branch information
atodorov authored and mulkieran committed Jun 4, 2015
1 parent d215b34 commit 7c0aca6
Show file tree
Hide file tree
Showing 27 changed files with 0 additions and 92 deletions.
5 changes: 0 additions & 5 deletions tests/action_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python

import unittest

Expand Down Expand Up @@ -1162,7 +1161,3 @@ def testContainerActions(self):
def testActionSorting(self, *args, **kwargs):
""" Verify correct functioning of action sorting. """
pass

if __name__ == "__main__":
unittest.main()

4 changes: 0 additions & 4 deletions tests/devicefactory_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python

import unittest

Expand Down Expand Up @@ -58,6 +57,3 @@ def testMDFactory(self):
self.assertEqual(self.factory2.container_list, [])

self.assertIsNone(self.factory2.get_container())

if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/devicelibs_test/mdraid_test.py 100755 → 100644
@@ -1,4 +1,3 @@
#!/usr/bin/python
import unittest

import blivet.devicelibs.mdraid as mdraid
Expand All @@ -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()
1 change: 0 additions & 1 deletion tests/devicelibs_test/raid_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
import unittest

import blivet.devicelibs.raid as raid
Expand Down
4 changes: 0 additions & 4 deletions tests/devices_test/dependencies_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
# vim:set fileencoding=utf-8

import unittest
Expand Down Expand Up @@ -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()
4 changes: 0 additions & 4 deletions tests/devices_test/device_names_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
# vim:set fileencoding=utf-8

import unittest
Expand Down Expand Up @@ -41,6 +40,3 @@ def testLogicalVolume(self):

for name in bad_names:
self.assertFalse(LVMLogicalVolumeDevice.isNameValid(name))

if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/devices_test/device_packages_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
# vim:set fileencoding=utf-8

import unittest
Expand Down Expand Up @@ -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()
4 changes: 0 additions & 4 deletions tests/devices_test/device_properties_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
# vim:set fileencoding=utf-8

import unittest
Expand Down Expand Up @@ -709,6 +708,3 @@ def testBTRFSSnapShotDeviceInit(self):

self.assertEqual(snap.dependsOn(vol), True)
self.assertEqual(vol.dependsOn(snap), False)

if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/devices_test/lvm_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
# vim:set fileencoding=utf-8

import unittest
Expand Down Expand Up @@ -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()
4 changes: 0 additions & 4 deletions tests/devices_test/network_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
# vim:set fileencoding=utf-8

import unittest
Expand Down Expand Up @@ -35,6 +34,3 @@ def testNetDevUpdate(self):
dev.create()

self.assertTrue("_netdev" in dev.format.options.split(","))

if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/devices_test/partition_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
# vim:set fileencoding=utf-8

import os
Expand Down Expand Up @@ -155,6 +154,3 @@ def testMinMaxSizeAlignment(self):
self.assertEqual(
disk.format.endAlignment.isAligned(free, max_end_sector),
True)

if __name__ == "__main__":
unittest.main()
3 changes: 0 additions & 3 deletions tests/devicetree_test.py
Expand Up @@ -278,6 +278,3 @@ def _set_up_storage(self):
None,
disks=self.blivet.disks[:],
container_raid_level="raid1")

if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/formats_test/device_test.py 100755 → 100644
@@ -1,4 +1,3 @@
#!/usr/bin/python
import unittest

import blivet
Expand Down Expand Up @@ -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()
4 changes: 0 additions & 4 deletions tests/formats_test/fs_test.py 100755 → 100644
@@ -1,4 +1,3 @@
#!/usr/bin/python
import os
import tempfile
import unittest
Expand Down Expand Up @@ -139,6 +138,3 @@ def tearDown(self):
except Exception: # pylint: disable=broad-except
pass
os.rmdir(self.mountpoint)

if __name__ == "__main__":
unittest.main()
1 change: 0 additions & 1 deletion tests/formats_test/fslabeling.py
@@ -1,4 +1,3 @@
#!/usr/bin/python

import abc
from six import add_metaclass
Expand Down
1 change: 0 additions & 1 deletion tests/formats_test/fstesting.py
@@ -1,4 +1,3 @@
#!/usr/bin/python

import abc
from six import add_metaclass
Expand Down
1 change: 0 additions & 1 deletion tests/formats_test/init_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
import copy
import unittest

Expand Down
4 changes: 0 additions & 4 deletions tests/formats_test/labeling_test.py 100755 → 100644
@@ -1,4 +1,3 @@
#!/usr/bin/python
import unittest

from tests import loopbackedtestcase
Expand Down Expand Up @@ -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()
4 changes: 0 additions & 4 deletions tests/formats_test/selinux_test.py 100755 → 100644
@@ -1,4 +1,3 @@
#!/usr/bin/python
import os
import selinux
import tempfile
Expand Down Expand Up @@ -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()
9 changes: 0 additions & 9 deletions tests/parentlist_test.py
Expand Up @@ -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()

4 changes: 0 additions & 4 deletions tests/partitioning_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python

import unittest
from mock import Mock
Expand Down Expand Up @@ -586,6 +585,3 @@ def testExplicitExtendedPartitions(self):
"user-specified extended partition was removed")

self.blivet.doIt()

if __name__ == "__main__":
unittest.main()
4 changes: 0 additions & 4 deletions tests/size_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
# pylint: disable=environment-modify
#
# tests/storage/size_tests.py
Expand Down Expand Up @@ -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()
1 change: 0 additions & 1 deletion tests/storagetestcase.py
@@ -1,4 +1,3 @@
#!/usr/bin/python

import unittest
from mock import Mock
Expand Down
1 change: 0 additions & 1 deletion tests/tasks_test/basic_tests.py
@@ -1,4 +1,3 @@
#!/usr/bin/python
import unittest

import blivet.tasks.task as task
Expand Down
3 changes: 0 additions & 3 deletions tests/tsort_test.py
Expand Up @@ -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()
5 changes: 0 additions & 5 deletions tests/udev_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python

import unittest
import mock
Expand Down Expand Up @@ -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()
1 change: 0 additions & 1 deletion tests/util_test.py
@@ -1,4 +1,3 @@
#!/usr/bin/python

import unittest
from decimal import Decimal
Expand Down

0 comments on commit 7c0aca6

Please sign in to comment.