{"action":"created","issue":{"url":"https://api.github.com/repos/rhinstaller/blivet/issues/120","labels_url":"https://api.github.com/repos/rhinstaller/blivet/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/rhinstaller/blivet/issues/120/comments","events_url":"https://api.github.com/repos/rhinstaller/blivet/issues/120/events","html_url":"https://github.com/rhinstaller/blivet/pull/120","id":79015894,"number":120,"title":"Run the test suite with both Python 2 and Python 3","user":{"login":"atodorov","id":1002300,"avatar_url":"https://avatars.githubusercontent.com/u/1002300?v=3","gravatar_id":"","url":"https://api.github.com/users/atodorov","html_url":"https://github.com/atodorov","followers_url":"https://api.github.com/users/atodorov/followers","following_url":"https://api.github.com/users/atodorov/following{/other_user}","gists_url":"https://api.github.com/users/atodorov/gists{/gist_id}","starred_url":"https://api.github.com/users/atodorov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atodorov/subscriptions","organizations_url":"https://api.github.com/users/atodorov/orgs","repos_url":"https://api.github.com/users/atodorov/repos","events_url":"https://api.github.com/users/atodorov/events{/privacy}","received_events_url":"https://api.github.com/users/atodorov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2015-05-21T14:21:31Z","updated_at":"2015-06-09T14:50:03Z","closed_at":"2015-06-09T14:50:03Z","pull_request":{"url":"https://api.github.com/repos/rhinstaller/blivet/pulls/120","html_url":"https://github.com/rhinstaller/blivet/pull/120","diff_url":"https://github.com/rhinstaller/blivet/pull/120.diff","patch_url":"https://github.com/rhinstaller/blivet/pull/120.patch"},"body":"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). \r\n\r\nThis PR introduces the following changes:\r\n\r\n- adds Makefile targets to execute the test suite under python 2 and 3 separately\r\n- make test now runs the test suite with *both* python 2 and 3\r\n- adds 2 separate targets to execute test suite with coverage report for python 2 and 3\r\n- adds new check-requires target which checks if Requires:/BuildRequires and a few manual added ones are present\r\n\r\n- 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. \r\n\r\n- 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. \r\n\r\n\r\nTODO:\r\n\r\nThere are still a few places which use hard-coded python version:\r\n- Makefile uses PYTHON=python2 which is used in a few places calling setup.py\r\n- some scripts/ use /usr/bin/python explicitly\r\n- runpylint.py uses /usr/bin/python3 explicitly\r\n\r\nmake 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.\r\n\r\nTest results:\r\n\r\nRunning the test suite with python2 gives me 4 errors:\r\n```\r\n======================================================================\r\nERROR: testAvailabilityMDRAIDplugin (devices_test.dependencies_test.MockingDeviceDependenciesTestCase)\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n  File \"/root/blivet/tests/devices_test/dependencies_test.py\", line 64, in testAvailabilityMDRAIDplugin\r\n    self.assertIsNotNone(ActionCreateFormat(self.luks, fmt=getFormat(\"macefi\")))\r\n  File \"blivet/deviceaction.py\", line 530, in __init__\r\n    raise ValueError(\"resource to create this format %s is unavailable\" % fmt)\r\nValueError: resource to create this format non-existent macefi filesystem is unavailable\r\n\r\n======================================================================\r\nERROR: testGetLabelArgs (formats_test.labeling_test.MethodsTestCase)\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n  File \"/root/blivet/tests/formats_test/labeling_test.py\", line 73, in testGetLabelArgs\r\n    reiserfs = self.fs[\"reiserfs\"]\r\nKeyError: 'reiserfs'\r\n\r\n======================================================================\r\nERROR: testActionDependencies (action_test.DeviceActionTestCase)\r\nVerify correct functioning of action dependencies.\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n  File \"/root/blivet/tests/action_test.py\", line 944, in testActionDependencies\r\n    format_lv = ActionCreateFormat(testlv, fmt)\r\n  File \"blivet/deviceaction.py\", line 530, in __init__\r\n    raise ValueError(\"resource to create this format %s is unavailable\" % fmt)\r\nValueError: resource to create this format non-existent None is unavailable\r\n\r\n======================================================================\r\nERROR: testContainerActions (action_test.DeviceActionTestCase)\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n  File \"/root/blivet/tests/action_test.py\", line 1122, in testContainerActions\r\n    fmt=new_lv_format)\r\n  File \"tests/storagetestcase.py\", line 245, in scheduleCreateFormat\r\n    action = blivet.deviceaction.ActionCreateFormat(device, fmt)\r\n  File \"blivet/deviceaction.py\", line 530, in __init__\r\n    raise ValueError(\"resource to create this format %s is unavailable\" % fmt)\r\nValueError: resource to create this format non-existent xfs filesystem is unavailable\r\n\r\n----------------------------------------------------------------------\r\nRan 467 tests in 704.377s\r\n\r\nFAILED (errors=4, skipped=319)\r\n```\r\n\r\nRunning with python3 gives me much more of the type:\r\n```\r\n======================================================================\r\nERROR: testMountingXFS (formats_test.selinux_test.SELinuxContextTestCase)\r\nXFS does not have a lost+found directory.\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n  File \"/root/blivet/tests/formats_test/selinux_test.py\", line 67, in testMountingXFS\r\n    an_fs = fs.XFS(device=self.loopDevices[0], label=\"test\")\r\n  File \"/root/blivet/blivet/formats/fs.py\", line 101, in __init__\r\n    DeviceFormat.__init__(self, **kwargs)\r\n  File \"/root/blivet/blivet/formats/__init__.py\", line 186, in __init__\r\n    self.device = kwargs.get(\"device\")\r\n  File \"/root/blivet/blivet/formats/__init__.py\", line 315, in <lambda>\r\n    lambda f,d: f._setDevice(d),\r\n  File \"/root/blivet/blivet/formats/__init__.py\", line 306, in _setDevice\r\n    error_msg = self._deviceCheck(devspec)\r\n  File \"/root/blivet/blivet/formats/__init__.py\", line 301, in _deviceCheck\r\n    if devspec and not devspec.startswith(\"/\"):\r\nTypeError: startswith first arg must be bytes or a tuple of bytes, not str\r\n\r\n----------------------------------------------------------------------\r\n\r\n\r\nI'm running on a recent F22 system upgraded to packages from the Rawhide repo. Let me know how would you like to proceed. \r\n```"},"comment":{"url":"https://api.github.com/repos/rhinstaller/blivet/issues/comments/110390242","html_url":"https://github.com/rhinstaller/blivet/pull/120#issuecomment-110390242","issue_url":"https://api.github.com/repos/rhinstaller/blivet/issues/120","id":110390242,"user":{"login":"mulkieran","id":1218366,"avatar_url":"https://avatars.githubusercontent.com/u/1218366?v=3","gravatar_id":"","url":"https://api.github.com/users/mulkieran","html_url":"https://github.com/mulkieran","followers_url":"https://api.github.com/users/mulkieran/followers","following_url":"https://api.github.com/users/mulkieran/following{/other_user}","gists_url":"https://api.github.com/users/mulkieran/gists{/gist_id}","starred_url":"https://api.github.com/users/mulkieran/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mulkieran/subscriptions","organizations_url":"https://api.github.com/users/mulkieran/orgs","repos_url":"https://api.github.com/users/mulkieran/repos","events_url":"https://api.github.com/users/mulkieran/events{/privacy}","received_events_url":"https://api.github.com/users/mulkieran/received_events","type":"User","site_admin":false},"created_at":"2015-06-09T14:50:03Z","updated_at":"2015-06-09T14:50:03Z","body":"It looks like everyone is OK with #151, so closing this one."}}