New: [rhinstaller/blivet/pulls/120 master] Run the test suite with both Python 2 and Python 3

atodorov installerbot-noreply at redhat.com
Thu May 21 14:21:32 UTC 2015


Since blivet is supposed to be compatible with both python 2 and 3 IMO it makes sense to run the test suite with both versions. (not to mention build the entire package with 2 or 3) At present only python2 is used to execute the test suite while python3 is used for pylint (due to pocketlint being python3 only). 

This PR introduces the following changes:

- adds Makefile targets to execute the test suite under python 2 and 3 separately
- make test now runs the test suite with *both* python 2 and 3
- adds 2 separate targets to execute test suite with coverage report for python 2 and 3
- adds new check-requires target which checks if Requires:/BuildRequires and a few manual added ones are present

- replaces `/usr/bin/python` with `/usr/bin/env python` inside test cases. NOTE: I don't see any executable tests/*.py files but maybe this is a good measure. Otherwise this line doesn't have any effect and can be removed. 

- updates the test cases to take care of several deprecation warnings coming from unittest. I've introduces a BlivetTestCase class which adds some aliases in case we're running with python2. 


TODO:

There are still a few places which use hard-coded python version:
- Makefile uses PYTHON=python2 which is used in a few places calling setup.py
- some scripts/ use /usr/bin/python explicitly
- runpylint.py uses /usr/bin/python3 explicitly

make check uses pocketlint which is Python3 only. I have not looked into how hard it will be to build it for Python2. Will do it tomorrow.

Test results:

Running the test suite with python2 gives me 4 errors:
```
======================================================================
ERROR: testAvailabilityMDRAIDplugin (devices_test.dependencies_test.MockingDeviceDependenciesTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/blivet/tests/devices_test/dependencies_test.py", line 64, in testAvailabilityMDRAIDplugin
    self.assertIsNotNone(ActionCreateFormat(self.luks, fmt=getFormat("macefi")))
  File "blivet/deviceaction.py", line 530, in __init__
    raise ValueError("resource to create this format %s is unavailable" % fmt)
ValueError: resource to create this format non-existent macefi filesystem is unavailable

======================================================================
ERROR: testGetLabelArgs (formats_test.labeling_test.MethodsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/blivet/tests/formats_test/labeling_test.py", line 73, in testGetLabelArgs
    reiserfs = self.fs["reiserfs"]
KeyError: 'reiserfs'

======================================================================
ERROR: testActionDependencies (action_test.DeviceActionTestCase)
Verify correct functioning of action dependencies.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/blivet/tests/action_test.py", line 944, in testActionDependencies
    format_lv = ActionCreateFormat(testlv, fmt)
  File "blivet/deviceaction.py", line 530, in __init__
    raise ValueError("resource to create this format %s is unavailable" % fmt)
ValueError: resource to create this format non-existent None is unavailable

======================================================================
ERROR: testContainerActions (action_test.DeviceActionTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/blivet/tests/action_test.py", line 1122, in testContainerActions
    fmt=new_lv_format)
  File "tests/storagetestcase.py", line 245, in scheduleCreateFormat
    action = blivet.deviceaction.ActionCreateFormat(device, fmt)
  File "blivet/deviceaction.py", line 530, in __init__
    raise ValueError("resource to create this format %s is unavailable" % fmt)
ValueError: resource to create this format non-existent xfs filesystem is unavailable

----------------------------------------------------------------------
Ran 467 tests in 704.377s

FAILED (errors=4, skipped=319)
```

Running with python3 gives me much more of the type:
```
======================================================================
ERROR: testMountingXFS (formats_test.selinux_test.SELinuxContextTestCase)
XFS does not have a lost+found directory.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/blivet/tests/formats_test/selinux_test.py", line 67, in testMountingXFS
    an_fs = fs.XFS(device=self.loopDevices[0], label="test")
  File "/root/blivet/blivet/formats/fs.py", line 101, in __init__
    DeviceFormat.__init__(self, **kwargs)
  File "/root/blivet/blivet/formats/__init__.py", line 186, in __init__
    self.device = kwargs.get("device")
  File "/root/blivet/blivet/formats/__init__.py", line 315, in <lambda>
    lambda f,d: f._setDevice(d),
  File "/root/blivet/blivet/formats/__init__.py", line 306, in _setDevice
    error_msg = self._deviceCheck(devspec)
  File "/root/blivet/blivet/formats/__init__.py", line 301, in _deviceCheck
    if devspec and not devspec.startswith("/"):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str

----------------------------------------------------------------------


I'm running on a recent F22 system upgraded to packages from the Rawhide repo. Let me know how would you like to proceed. 
```
-- 
To view this pull request on github, visit https://github.com/rhinstaller/blivet/pull/120


More information about the anaconda-patches mailing list