Hello community, here is the log from the commit of package python-parted for openSUSE:Factory checked in at 2018-05-29 16:51:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-parted (Old) and /work/SRC/openSUSE:Factory/.python-parted.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-parted" Tue May 29 16:51:08 2018 rev:2 rq:611907 version:3.11.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-parted/python-parted.changes 2017-04-11 09:45:03.821924259 +0200 +++ /work/SRC/openSUSE:Factory/.python-parted.new/python-parted.changes 2018-05-29 16:51:23.965751029 +0200 @@ -1,0 +2,24 @@ +Thu May 24 15:26:23 UTC 2018 - tchva...@suse.com + +- Add patch to tweak features detected in tests (parted changes + from suse): + * python-parted-featurestest.patch +- Add patch python-parted-parted-binary.patch to run parted full + path as user does not see sbin binaries +- Add patch no-last-flag-check.patch from debian +- Add patch python-parted-unittests.patch from ubuntu to fix tests + +------------------------------------------------------------------- +Thu May 24 14:49:05 UTC 2018 - tchva...@suse.com + +- Implement singlespec version for python3 +- Refresh patch pyparted-3.10.patch to work with python3 +- Enable testsuite to validate it somehow + +------------------------------------------------------------------- +Thu May 24 12:08:12 UTC 2018 - bwiedem...@suse.com + +- Update to 3.11.1 + * make package build reproducible (boo#1041090) + +------------------------------------------------------------------- Old: ---- pyparted-3.10.7.tar.gz New: ---- no-last-flag-check.patch pyparted-3.11.1.tar.gz python-parted-featurestest.patch python-parted-parted-binary.patch python-parted-unittests.patch ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-parted.spec ++++++ --- /var/tmp/diff_new_pack.HDSiG1/_old 2018-05-29 16:51:25.641689363 +0200 +++ /var/tmp/diff_new_pack.HDSiG1/_new 2018-05-29 16:51:25.641689363 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-parted # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,24 +16,34 @@ # -Summary: Python module for GNU parted -License: GPL-2.0+ -Group: Development/Languages/Python -Name: python-parted %define srcname pyparted -Version: 3.10.7 +%{?!python_module:%define python_module() python-%{**} python3-%{**}} +Name: python-parted +Version: 3.11.1 Release: 0 -Url: http://fedorahosted.org/pyparted - -Source0: https://pypi.org/packages/source/p/%{srcname}/%{srcname}-%{version}.tar.gz +Summary: Python module for GNU parted +License: GPL-2.0-or-later +Group: Development/Languages/Python +URL: https://github.com/dcantrell/pyparted/ +Source0: https://github.com/dcantrell/pyparted/archive/v3.11.1.tar.gz#/%{srcname}-%{version}.tar.gz # catch exception for unknown 'disk flag', kkae...@suse.de -Patch: pyparted-3.10.patch - -BuildRoot: %{_tmppath}/%{name}-%{version}-build +Patch0: pyparted-3.10.patch +# do not check for PED_PARTITION)_LAST_FLAG as it is not part of ABI +Patch1: no-last-flag-check.patch +Patch2: python-parted-unittests.patch +Patch3: python-parted-parted-binary.patch +Patch4: python-parted-featurestest.patch +BuildRequires: %{python_module devel} +BuildRequires: %{python_module six} +# tests requires +BuildRequires: e2fsprogs +BuildRequires: parted +Requires: parted BuildRequires: fdupes BuildRequires: parted-devel BuildRequires: pkgconfig -BuildRequires: python-devel >= 2.7 +BuildRequires: python-rpm-macros +%python_subpackages %description Python module for the parted library. It is used for manipulating @@ -41,20 +51,22 @@ %prep %setup -q -n %{srcname}-%{version} -%patch -p1 +%autopatch -p1 %build -make %{?_smp_mflags} +%python_build %install -make install DESTDIR=%{buildroot} +%python_install +%python_expand %fdupes %{buildroot}%{$python_sitearch} -%fdupes %{buildroot} +%check +%python_expand PYTHONPATH=%{buildroot}%{$python_sitearch} $python -m unittest discover -v -%files -%defattr(-,root,root,-) -%doc AUTHORS COPYING NEWS README TODO -%{python_sitearch}/_ped.so +%files %{python_files} +%license COPYING +%doc AUTHORS NEWS README TODO +%{python_sitearch}/_ped*.so %{python_sitearch}/parted %{python_sitearch}/%{srcname}-%{version}-*.egg-info ++++++ no-last-flag-check.patch ++++++ Description: Remove *_LAST_FLAG checks The last flag in an enumeration is not really part of the ABI. Checking it here means that changes to parted may unexpectedly break pyparted. Author: Colin Watson <cjwat...@debian.org> Reviewed-by: Herbert Parentes Fortes Neto <h...@ig.com.br> Bug-Debian: http://bugs.debian.org/697588 Last-Update: 2014-11-30 --- a/src/pydisk.c +++ b/src/pydisk.c @@ -1020,7 +1020,7 @@ return NULL; } - if ((flag < PED_DISK_FIRST_FLAG) || (flag > PED_DISK_LAST_FLAG)) { + if ((flag < PED_DISK_FIRST_FLAG)) { PyErr_SetString(PyExc_ValueError, "Invalid flag provided."); return NULL; } @@ -1404,7 +1404,7 @@ return NULL; } - if ((flag < PED_PARTITION_FIRST_FLAG) || (flag > PED_PARTITION_LAST_FLAG)) { + if ((flag < PED_PARTITION_FIRST_FLAG)) { PyErr_SetString(PyExc_ValueError, "Invalid flag provided."); return NULL; } ++++++ pyparted-3.10.patch ++++++ --- /var/tmp/diff_new_pack.HDSiG1/_old 2018-05-29 16:51:25.665688480 +0200 +++ /var/tmp/diff_new_pack.HDSiG1/_new 2018-05-29 16:51:25.665688480 +0200 @@ -9,4 +9,4 @@ + try: + diskFlag[__flag] = _ped.disk_flag_get_name(__flag) + except: -+ print "Bad disk flag:", __flag ++ print("Bad disk flag: {}".format(__flag)) ++++++ pyparted-3.10.7.tar.gz -> pyparted-3.11.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/.gitignore new/pyparted-3.11.1/.gitignore --- old/pyparted-3.10.7/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/pyparted-3.11.1/.gitignore 2017-06-26 17:20:05.000000000 +0200 @@ -0,0 +1,10 @@ +*.pyc +*.swp +ChangeLog +MANIFEST +build +dist +pyparted.spec +.tox +.coverage +coverage-report.log diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/HACKING new/pyparted-3.11.1/HACKING --- old/pyparted-3.10.7/HACKING 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/HACKING 2017-06-26 17:20:05.000000000 +0200 @@ -184,7 +184,7 @@ and commit your changes locally and then generate a set of diffs against the latest upstream code. - $ git clone https://github.com/rhinstaller/pyparted.git + $ git clone https://github.com/dcantrell/pyparted.git $ cd pyparted $ # make your changes to files here $ git add FILE # repeat this add/commit process for @@ -203,7 +203,7 @@ The best way to submit patches is to fork the repo on github and send a pull request with your changes: - https://github.com/rhinstaller/pyparted + https://github.com/dcantrell/pyparted Attach your patch and explanation and it'll be reviewed. There may be some back and forth as your patch is reviewed and considered for inclusion. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/Makefile new/pyparted-3.11.1/Makefile --- old/pyparted-3.10.7/Makefile 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/Makefile 2017-06-26 17:20:05.000000000 +0200 @@ -47,6 +47,7 @@ @env PYTHONPATH=$$(find $$(pwd) -name "*.so" | head -n 1 | xargs dirname):src/parted:src \ $(COVERAGE) run --branch -m unittest discover -v $(COVERAGE) report --include="build/lib.*/parted/*" --show-missing + $(COVERAGE) report --include="build/lib.*/parted/*" > coverage-report.log check: clean env PYTHON=python3 $(MAKE) ; \ @@ -103,4 +104,7 @@ clean: -rm -r build -ci: check test +ci: check coverage + +verrel: + @echo $(PACKAGE)-$(VERSION) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/PKG-INFO new/pyparted-3.11.1/PKG-INFO --- old/pyparted-3.10.7/PKG-INFO 2017-03-13 06:13:15.000000000 +0100 +++ new/pyparted-3.11.1/PKG-INFO 1970-01-01 01:00:00.000000000 +0100 @@ -1,10 +0,0 @@ -Metadata-Version: 1.0 -Name: pyparted -Version: 3.10.7 -Summary: Python bindings for GNU parted -Home-page: https://fedorahosted.org/pyparted/ -Author: pyparted Development Team -Author-email: pyparted-de...@redhat.com -License: GPLv2+ -Description: UNKNOWN -Platform: UNKNOWN diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/RELEASE new/pyparted-3.11.1/RELEASE --- old/pyparted-3.10.7/RELEASE 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/RELEASE 2017-06-26 17:20:05.000000000 +0200 @@ -8,7 +8,9 @@ 4) make bumpver 5) git commit -a -m "New version." 6) git clean -d -x -f -7) make release +7) make dist +8) gpg --detach-sign -a dist/$(make verrel).tar.gz +8) twine upload dist/$(make verrel).tar.gz $(make verrel).tar.gz.asc If packaging in RPM format, you might find the 'make rpmlog' target useful. It gives you an RPM spec file formatted changelog block that contains the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/examples/make_one_primary_partition.py new/pyparted-3.11.1/examples/make_one_primary_partition.py --- old/pyparted-3.10.7/examples/make_one_primary_partition.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pyparted-3.11.1/examples/make_one_primary_partition.py 2017-06-26 17:20:05.000000000 +0200 @@ -0,0 +1,129 @@ +# coding=utf-8 +# +# Copyright 2015 John Florian <jflor...@doubledog.org> +# +# This example script is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version so long as this copyright notice remains intact. +# +# This example script is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this example script. If not, see <http://www.gnu.org/licenses/>. + +""" +An example program that creates a single, bootable primary partition on a disk. +""" +from glob import glob +from logging import getLogger +import logging + +import parted + + +__author__ = """John Florian <john.flor...@dart.biz>""" +__copyright__ = """Copyright 2015 John Florian""" + + +class _ConsoleHandler(logging.StreamHandler): + def __init__(self): + super().__init__() + self.setFormatter( + logging.Formatter('{levelname} - {message}', style='{') + ) + + +class ExampleDevice(object): + """ + A simple model of a block storage device that wraps up some examples of + pyparted capabilities. + """ + + def __init__(self, path): + """ + Initialize the ExampleDevice object. + """ + self.path = path + self.logger = getLogger(__name__) + + @property + def partition_names(self): + """ + @return: A list of partition device names on the block device. + @rtype: str + """ + names = glob('{}[0-9]*'.format(self.path)) + self.logger.debug('has partitions %s', names) + return names + + def partition(self): + """ + Create a partition table on the block device. + + The newly created partition will have the following characteristics: + - a primary partition using 100% of the device capacity + - optimal alignment given the disk topology information + - a MS-DOS disk label for simple BIOS booting on PC-type hardware + - marked as bootable + """ + self.logger.info('creating primary partition') + device = parted.getDevice(self.path) + self.logger.debug('created %s', device) + disk = parted.freshDisk(device, 'msdos') + self.logger.debug('created %s', disk) + geometry = parted.Geometry(device=device, start=1, + length=device.getLength() - 1) + self.logger.debug('created %s', geometry) + filesystem = parted.FileSystem(type='ext3', geometry=geometry) + self.logger.debug('created %s', filesystem) + partition = parted.Partition(disk=disk, type=parted.PARTITION_NORMAL, + fs=filesystem, geometry=geometry) + self.logger.debug('created %s', partition) + disk.addPartition(partition=partition, + constraint=device.optimalAlignedConstraint) + partition.setFlag(parted.PARTITION_BOOT) + disk.commit() + + def wipe_dev(self, dev_path): + """ + Wipe a device (partition or otherwise) of meta-data, be it file system, + LVM, etc. + + @param dev_path: Device path of the partition to be wiped. + @type dev_path: str + """ + self.logger.debug('wiping %s', dev_path) + with open(dev_path, 'wb') as p: + p.write(bytearray(1024)) + + def wipe(self): + """ + Wipe the block device of meta-data, be it file system, LVM, etc. + + This is not intended to be secure, but rather to ensure that + auto-discovery tools don't recognize anything here. + """ + self.logger.info('wiping partitions and other meta-data') + for partition in self.partition_names: + self.wipe_dev(partition) + self.wipe_dev(self.path) + + +if __name__ == '__main__': + # It should be plenty obvious what needs to be done here. If it's not + # obvious to you, please don't run this!!! + my_unimportant_test_disk = '/dev/sdX__FIXME' + + # Set up a logger for nice visibility. + logger = getLogger(__name__) + logger.setLevel(logging.DEBUG) + logger.addHandler(_ConsoleHandler()) + + # Ok, now for the good stuff, the actual example. + guinea_pig = ExampleDevice(my_unimportant_test_disk) + guinea_pig.wipe() + guinea_pig.partition() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/setup.py new/pyparted-3.11.1/setup.py --- old/pyparted-3.10.7/setup.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/setup.py 2017-06-26 17:20:05.000000000 +0200 @@ -1,5 +1,5 @@ # setup.py script for pyparted -# Copyright (C) 2011-2013 Red Hat, Inc. +# Copyright (C) 2011-2017 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,8 +30,9 @@ from distutils.errors import LinkError from distutils.core import setup from distutils.core import Extension +from distutils.version import LooseVersion -pyparted_version = '3.10.7' +pyparted_version = '3.11.1' python_version = sys.version_info need_libparted_version = '2.3' @@ -50,8 +51,8 @@ return kwargs def check_mod_version(module, version): - modversion = subprocess.check_output(["pkg-config", "--modversion", module]) - if not float(modversion) >= float(version): + modversion = subprocess.check_output(["pkg-config", "--modversion", module]).decode('utf-8').split()[0] + if not LooseVersion(modversion) >= LooseVersion(version): sys.stderr.write("*** Minimum required %s version: %s, found: %s\n" % (module, version, modversion,)) sys.exit(1) return @@ -65,15 +66,15 @@ setup(name='pyparted', version=pyparted_version, - author='pyparted Development Team', - author_email='pyparted-de...@redhat.com', - url='https://fedorahosted.org/pyparted/', + author='David Cantrell', + author_email='dcantr...@redhat.com', + url='https://github.com/dcantrell/pyparted/', description='Python bindings for GNU parted', license='GPLv2+', packages=['parted'], package_dir={'parted': 'src/parted'}, ext_modules=[Extension('_ped', - glob.glob(os.path.join('src', '*.c')), + sorted(glob.glob(os.path.join('src', '*.c'))), define_macros=features, **pkgconfig('libparted', include_dirs=['include'])) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/_pedmodule.c new/pyparted-3.11.1/src/_pedmodule.c --- old/pyparted-3.10.7/src/_pedmodule.c 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/_pedmodule.c 2017-06-26 17:20:05.000000000 +0200 @@ -634,15 +634,9 @@ PyModule_AddIntConstant(m, "PARTITION_BIOS_GRUB", PED_PARTITION_BIOS_GRUB); PyModule_AddIntConstant(m, "PARTITION_DIAG", PED_PARTITION_DIAG); PyModule_AddIntConstant(m, "PARTITION_LEGACY_BOOT", PED_PARTITION_LEGACY_BOOT); -#ifdef PED_PARTITION_MSFT_DATA PyModule_AddIntConstant(m, "PARTITION_MSFT_DATA", PED_PARTITION_MSFT_DATA); -#endif -#ifdef PED_PARTITION_IRST PyModule_AddIntConstant(m, "PARTITION_IRST", PED_PARTITION_IRST); -#endif -#ifdef PED_PARTITION_ESP PyModule_AddIntConstant(m, "PARTITION_ESP", PED_PARTITION_ESP); -#endif PyModule_AddIntConstant(m, "DISK_CYLINDER_ALIGNMENT", PED_DISK_CYLINDER_ALIGNMENT); PyModule_AddIntConstant(m, "DISK_GPT_PMBR_BOOT", PED_DISK_GPT_PMBR_BOOT); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/fdisk/fdisk.py new/pyparted-3.11.1/src/fdisk/fdisk.py --- old/pyparted-3.10.7/src/fdisk/fdisk.py 1970-01-01 01:00:00.000000000 +0100 +++ new/pyparted-3.11.1/src/fdisk/fdisk.py 2017-06-26 17:20:05.000000000 +0200 @@ -0,0 +1,182 @@ +# +# fdisk.py +# Partitioning utility with an fdisk-style interface, but written in +# Python and using the pyparted Python module. +# +# Copyright (C) 2009 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. You should have received a copy of the +# GNU General Public License along with this program; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): David Cantrell <dcantr...@redhat.com> +# + +import getopt +import os +import parted +import sys + +def usage(cmd): + sys.stdout.write("Usage: %s [-b SSZ] [-u] DISK Change partition table\n" % (cmd,)) + sys.stdout.write(" %s [-l] [-b SSZ] [-u] DISK List partition table(s)\n" % (cmd,)) + sys.stdout.write(" %s -s PARTITION Give partition size(s) in blocks\n\n" % (cmd,)) + sys.stdout.write("Here DISK is something like /dev/hdb or /dev/sda\n") + sys.stdout.write("and PARTITION is something like /dev/hda7\n\n") + sys.stdout.write("Options:\n") + sys.stdout.write(" -b=SSZ, --sectorsize=SSZ Sector size (in bytes) to use\n") + sys.stdout.write(" -l, --list List partition table(s)\n") + sys.stdout.write(" -u, --showsectors Give Start and End in sector units\n") + sys.stdout.write(" -s, --showblocks Give Start and End in block units\n") + sys.stdout.write(" -V, --version Show fdisk version\n") + sys.stdout.write(" -?, --help Display fdisk usage screen\n") + +def displayVersion(cmd): + ver = parted.version() + + sys.stdout.write("%s:\n" % (cmd,)) + sys.stdout.write("pyparted version: %s.%s.%s\n" % (ver["pyparted"][0], ver["pyparted"][1], ver["pyparted"][2])) + sys.stdout.write("libparted version: %s\n" % ver["libparted"]) + +def listPartitionTable(path, sectorsize, showsectors, showblocks): + device = parted.getDevice(path) + (cylinders, heads, sectors) = device.biosGeometry + sizeInBytes = device.length * device.sectorSize + disk = parted.Disk(device) + + partlist = [] + for partition in disk.partitions: + if partition.type == parted.PARTITION_PROTECTED or \ + partition.type == parted.PARTITION_METADATA or \ + partition.type == parted.PARTITION_FREESPACE: + continue + + partlist.append((partition, + partition.path, + partition.getFlag(parted.PARTITION_BOOT), + partition.geometry.start, + partition.geometry.end, + partition.geometry.length, + partition.type, + partition.fileSystem)) + + colLength = 0 + for parts in partlist: + path = parts[1] + if len(path) > colLength: + colLength = len(path) + + sys.stdout.write("Disk %s: %%d %%s, %d bytes\n" % (disk.device.path, sizeInBytes)) + sys.stdout.write("%d heads, %d sectors/track, %d cylinders\n" % (heads, sectors, cylinders,)) + sys.stdout.write("Units = FIXME\n") + sys.stdout.write("Disk identifier: FIXME\n\n") + + sys.stdout.write("%-11s %-4s %-11s %-11s %-12s %-4s %s\n" % ("Device", "Boot", "Start", "End", "Blocks", "Id", "System",)) + + for parts in partlist: + (partition, path, bootable, start, end, length, ty, fs) = parts + + if bootable: + bootflag = '*' + else: + bootflag = '' + + sys.stdout.write("%-11s %-4s %-11d %-11d %-12d %-4s" % (path, bootflag, start, end, length, ty,)) + + if fs is None: + # no filesystem, check flags + if partition.getFlag(parted.PARTITION_SWAP): + sys.stdout.write(" Linux swap\n") + elif partition.getFlag(parted.PARTITION_RAID): + sys.stdout.write(" RAID\n") + elif partition.getFlag(parted.PARTITION_LVM): + sys.stdout.write(" Linux LVM\n") + elif partition.getFlag(parted.PARTITION_HPSERVICE): + sys.stdout.write(" HP Service\n") + elif partition.getFlag(parted.PARTITION_PALO): + sys.stdout.write(" PALO\n") + elif partition.getFlag(parted.PARTITION_PREP): + sys.stdout.write(" PReP\n") + elif partition.getFlag(parted.MSFT_RESERVED): + sys.stdout.write(" MSFT Reserved\n") + else: + sys.stdout.write(" unknown\n") + else: + sys.stdout.write(" %s\n" % (fs.type,)) + +#Disk /dev/sda: 250.0 GB, 250059350016 bytes +#255 heads, 63 sectors/track, 30401 cylinders +#Units = cylinders of 16065 * 512 = 8225280 bytes +#Disk identifier: 0x00000000 +# +# Device Boot Start End Blocks Id System +#/dev/sda1 1 26 204819+ ee GPT +#/dev/sda2 26 4203 33554432 af Unknown +#/dev/sda3 * 4203 4229 204800 83 Linux +#/dev/sda4 4229 30402 210234515+ 8e Linux LVM + +def main(argv): + cmd = os.path.basename(sys.argv[0]) + opts, args = [], [] + showhelp, showlist, showsectors, showblocks = False, False, False, False + + # These three are unused for now so I'm marking them with an underscore + # to make pylint happy. + sectorsize, _cylinders, _heads, _sectors = None, None, None, None + + if len(sys.argv) == 1: + showhelp = True + + try: + opts, args = getopt.getopt(sys.argv[1:], "lb:C:H:S:usV?", + ["list", "sectorsize=", "cylinders=", + "heads=", "sectors=", "showsectors", + "showblocks", "version", "help"]) + except getopt.GetoptError: + showhelp = True + + for o, a in opts: + if o in ('-l', '--list'): + showlist = True + elif o in ('-b', '--sectorsize'): + sectorsize = a + elif o in ('-C', '--cylinders'): + _cylinders = a + elif o in ('-H', '--heads'): + _heads = a + elif o in ('-S', '--sectors'): + _sectors = a + elif o in ('-u', '--showsectors'): + showsectors = True + elif o in ('-s', '--showblocks'): + showblocks = True + elif o in ('-V', '--version'): + displayVersion(cmd) + sys.exit(0) + elif o in ('-?', '--help'): + usage(cmd) + sys.exit(0) + else: + sys.stderr.write("Invalid option: %s\n\n" % (o,)) + showhelp = True + + if showhelp: + usage(cmd) + sys.exit(1) + + for arg in args: + if showlist: + listPartitionTable(arg, sectorsize, showsectors, showblocks) + +if __name__ == "__main__": + main(sys.argv) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/fdisk/localtest new/pyparted-3.11.1/src/fdisk/localtest --- old/pyparted-3.10.7/src/fdisk/localtest 1970-01-01 01:00:00.000000000 +0100 +++ new/pyparted-3.11.1/src/fdisk/localtest 2017-06-26 17:20:05.000000000 +0200 @@ -0,0 +1,3 @@ +#!/bin/sh +export PYTHONPATH=$(pwd)/..:$(pwd)/../.libs +python fdisk.py $* diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/parted/__init__.py new/pyparted-3.11.1/src/parted/__init__.py --- old/pyparted-3.10.7/src/parted/__init__.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/parted/__init__.py 2017-06-26 17:20:05.000000000 +0200 @@ -25,6 +25,7 @@ from __future__ import division +import math import platform import re import sys @@ -129,6 +130,9 @@ if hasattr(_ped, 'PARTITION_ESP'): # pylint: disable=E0611 from _ped import PARTITION_ESP +if hasattr(_ped, 'PARTITION_NONFS'): + # pylint: disable=E0611 + from _ped import PARTITION_NONFS from _ped import DISK_CYLINDER_ALIGNMENT from _ped import DISK_GPT_PMBR_BOOT @@ -307,7 +311,7 @@ if unit not in __exponents.keys(): raise SyntaxError("{:} is not a valid SI or IEC byte unit".format(unit)) else: - return bytes_ * __exponents[unit] // sector_size + return math.ceil(bytes_ * __exponents[unit] / sector_size) # Valid disk labels per architecture type. The list of label # names map to keys in the parted.diskType hash table. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/parted/cachedlist.py new/pyparted-3.11.1/src/parted/cachedlist.py --- old/pyparted-3.10.7/src/parted/cachedlist.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/parted/cachedlist.py 2017-06-26 17:20:05.000000000 +0200 @@ -82,9 +82,9 @@ self.__rebuildList() return self._lst.count(value) - def index(self, value): + def index(self, value, *args, **kwargs): self.__rebuildList() - return self._lst.index(value) + return self._lst.index(value, *args, **kwargs) def invalidate(self): """Indicate that the list is no longer valid, due to some external diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/parted/constraint.py new/pyparted-3.11.1/src/parted/constraint.py --- old/pyparted-3.10.7/src/parted/constraint.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/parted/constraint.py 2017-06-26 17:20:05.000000000 +0200 @@ -44,7 +44,7 @@ __init__. If minGeom and maxGeom are supplied, the constraint will be created to satisfy both. If only one of minGeom or maxGeom are supplied, the constraint is only guaranteed to solve the given - paramter. If exactGeom is given, the constraint will only be + parameter. If exactGeom is given, the constraint will only be satisfied by the given geometry. If device is given, any region on that device will satisfy the constraint. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/parted/device.py new/pyparted-3.11.1/src/parted/device.py --- old/pyparted-3.10.7/src/parted/device.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/parted/device.py 2017-06-26 17:20:05.000000000 +0200 @@ -37,11 +37,11 @@ class Device(object): """Device() - Device represents a phyiscal piece of hardware in the system, e.g. a + Device represents a physical piece of hardware in the system, e.g. a disk. A Device should be considered a low-level and operating system specific interface to the hardware. - A number of read-only properties about the Device are available. + A number of read-only properties of the Device are available. For information on the individual methods, see help(Device.METHODNAME)""" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/parted/disk.py new/pyparted-3.11.1/src/parted/disk.py --- old/pyparted-3.10.7/src/parted/disk.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/parted/disk.py 2017-06-26 17:20:05.000000000 +0200 @@ -56,15 +56,15 @@ self._partitions = CachedList(lambda : self.__getPartitions()) def _hasSameParts(self, other): - import itertools + import six if len(self.partitions) != len(other.partitions): return False - partIter = itertools.izip(self.partitions, other.partitions) + partIter = six.moves.zip(self.partitions, other.partitions) while True: try: - (left, right) = partIter.next() + (left, right) = next(partIter) if left != right: return False except StopIteration: @@ -351,38 +351,6 @@ returned (not the extended partition).""" return parted.Partition(disk=self, PedPartition=self.__disk.get_partition_by_sector(sector)) - def getMaxLogicalPartitions(self): - """Return the maximum number of logical partitions this Disk - will hold. Returns 0 if there is no extended partition on - the disk, returns 11 when all else fails.""" - if not self.supportsFeature(parted.DISK_TYPE_EXTENDED): - return 0 - - # maximum number of logical partitions per device type - maxLogicalPartitionCount = { - "hd": 59, - "sd": 11, - "ataraid/": 11, - "rd/": 3, - "cciss/": 11, - "i2o/": 11, - "iseries/vd": 3, - "ida/": 11, - "sx8/": 11, - "xvd": 11, - "vd": 11, - "mmcblk": 5 - } - - dev = self.device.path[5:] - for key in maxLogicalPartitionCount.keys(): - if dev.startswith(key): - return maxLogicalPartitionCount[key] - - # XXX: if we don't know about it, should we pretend it can't have - # logicals? probably safer to just use something reasonable - return 11 - @localeC def getExtendedPartition(self): """Return the extended Partition, if any, on this Disk.""" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/pyconstraint.c new/pyparted-3.11.1/src/pyconstraint.c --- old/pyparted-3.10.7/src/pyconstraint.c 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/pyconstraint.c 2017-06-26 17:20:05.000000000 +0200 @@ -264,9 +264,9 @@ } if (!strcmp(member, "min_size")) { - return PyLong_FromLong(self->min_size); + return PyLong_FromLongLong(self->min_size); } else if (!strcmp(member, "max_size")) { - return PyLong_FromLong(self->max_size); + return PyLong_FromLongLong(self->max_size); } else { PyErr_Format(PyExc_AttributeError, "_ped.Constraint object has no attribute %s", member); return NULL; @@ -282,12 +282,12 @@ } if (!strcmp(member, "min_size")) { - self->min_size = PyLong_AsLong(value); + self->min_size = PyLong_AsLongLong(value); if (PyErr_Occurred()) { return -1; } } else if (!strcmp(member, "max_size")) { - self->max_size = PyLong_AsLong(value); + self->max_size = PyLong_AsLongLong(value); if (PyErr_Occurred()) { return -1; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/pydevice.c new/pyparted-3.11.1/src/pydevice.c --- old/pyparted-3.10.7/src/pydevice.c 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/pydevice.c 2017-06-26 17:20:05.000000000 +0200 @@ -266,11 +266,11 @@ } else if (!strcmp(member, "type")) { return PyLong_FromLong(self->type); } else if (!strcmp(member, "sector_size")) { - return PyLong_FromLong(self->sector_size); + return PyLong_FromLongLong(self->sector_size); } else if (!strcmp(member, "phys_sector_size")) { - return PyLong_FromLong(self->phys_sector_size); + return PyLong_FromLongLong(self->phys_sector_size); } else if (!strcmp(member, "length")) { - return PyLong_FromLong(self->length); + return PyLong_FromLongLong(self->length); } else if (!strcmp(member, "open_count")) { return Py_BuildValue("i", self->open_count); } else if (!strcmp(member, "read_only")) { @@ -819,7 +819,7 @@ ret = ped_device_check(device, out_buf, start, count); free(out_buf); - return PyLong_FromLong(ret); + return PyLong_FromLongLong(ret); } PyObject *py_ped_device_get_constraint(PyObject *s, PyObject *args) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/pydisk.c new/pyparted-3.11.1/src/pydisk.c --- old/pyparted-3.10.7/src/pydisk.c 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/pydisk.c 2017-06-26 17:20:05.000000000 +0200 @@ -928,7 +928,7 @@ if (!disk) return NULL; - return PyLong_FromUnsignedLong(ped_disk_max_partition_length(disk)); + return PyLong_FromUnsignedLongLong(ped_disk_max_partition_length(disk)); } PyObject *py_ped_disk_max_partition_start_sector(PyObject *s, PyObject *args) { @@ -938,7 +938,7 @@ if (!disk) return NULL; - return PyLong_FromUnsignedLong(ped_disk_max_partition_start_sector(disk)); + return PyLong_FromUnsignedLongLong(ped_disk_max_partition_start_sector(disk)); } PyObject *py_ped_disk_set_flag(PyObject *s, PyObject *args) { @@ -1217,9 +1217,11 @@ return NULL; } - out_fstype = _ped_FileSystemType2PedFileSystemType(in_fstype); - if (out_fstype == NULL) { - return NULL; + if (in_fstype != NULL) { + out_fstype = _ped_FileSystemType2PedFileSystemType(in_fstype); + if (out_fstype == NULL) { + return NULL; + } } /* ped_partition_set_system will assert on this. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/pygeom.c new/pyparted-3.11.1/src/pygeom.c --- old/pyparted-3.10.7/src/pygeom.c 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/pygeom.c 2017-06-26 17:20:05.000000000 +0200 @@ -183,11 +183,11 @@ } if (!strcmp(member, "start")) { - return PyLong_FromLong(self->ped_geometry->start); + return PyLong_FromLongLong(self->ped_geometry->start); } else if (!strcmp(member, "length")) { - return PyLong_FromLong(self->ped_geometry->length); + return PyLong_FromLongLong(self->ped_geometry->length); } else if (!strcmp(member, "end")) { - return PyLong_FromLong(self->ped_geometry->end); + return PyLong_FromLongLong(self->ped_geometry->end); } else { PyErr_Format(PyExc_AttributeError, "_ped.Geometry object has no attribute %s", member); return NULL; @@ -205,20 +205,20 @@ } if (!strcmp(member, "start")) { - val = PyLong_AsLong(value); + val = PyLong_AsLongLong(value); if (PyErr_Occurred()) { return -1; } ret = ped_geometry_set_start(self->ped_geometry, val); } else if (!strcmp(member, "length")) { - val = PyLong_AsLong(value); + val = PyLong_AsLongLong(value); if (PyErr_Occurred()) { return -1; } ret = ped_geometry_set(self->ped_geometry, self->ped_geometry->start, val); } else if (!strcmp(member, "end")) { - val = PyLong_AsLong(value); + val = PyLong_AsLongLong(value); if (PyErr_Occurred()) { return -1; } @@ -717,7 +717,7 @@ ped_timer_destroy(out_timer); free(out_buf); - return PyLong_FromLong(ret); + return PyLong_FromLongLong(ret); } PyObject *py_ped_geometry_map(PyObject *s, PyObject *args) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/src/pynatmath.c new/pyparted-3.11.1/src/pynatmath.c --- old/pyparted-3.10.7/src/pynatmath.c 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/src/pynatmath.c 2017-06-26 17:20:05.000000000 +0200 @@ -126,9 +126,9 @@ } if (!strcmp(member, "offset")) { - return PyLong_FromLong(self->offset); + return PyLong_FromLongLong(self->offset); } else if (!strcmp(member, "grain_size")) { - return PyLong_FromLong(self->grain_size); + return PyLong_FromLongLong(self->grain_size); } else { PyErr_Format(PyExc_AttributeError, "_ped.Alignment object has no attribute %s", member); return NULL; @@ -143,12 +143,12 @@ } if (!strcmp(member, "offset")) { - self->offset = PyLong_AsLong(value); + self->offset = PyLong_AsLongLong(value); if (PyErr_Occurred()) { return -1; } } else if (!strcmp(member, "grain_size")) { - self->grain_size = PyLong_AsLong(value); + self->grain_size = PyLong_AsLongLong(value); if (PyErr_Occurred()) { return -1; } @@ -252,7 +252,7 @@ return NULL; } - return PyLong_FromLong(ret); + return PyLong_FromLongLong(ret); } PyObject *py_ped_alignment_align_down(PyObject *s, PyObject *args) { @@ -284,7 +284,7 @@ return NULL; } - return PyLong_FromLong(ret); + return PyLong_FromLongLong(ret); } PyObject *py_ped_alignment_align_nearest(PyObject *s, PyObject *args) { @@ -316,7 +316,7 @@ return NULL; } - return PyLong_FromLong(ret); + return PyLong_FromLongLong(ret); } PyObject *py_ped_alignment_is_aligned(PyObject *s, PyObject *args) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/README.rst new/pyparted-3.11.1/tests/README.rst --- old/pyparted-3.10.7/tests/README.rst 1970-01-01 01:00:00.000000000 +0100 +++ new/pyparted-3.11.1/tests/README.rst 2017-06-26 17:20:05.000000000 +0200 @@ -0,0 +1,67 @@ +Testing pyparted +================ + +Pyparted test suite inherits from the standard :class:`unittest.TestCase` class. +To execute it from inside the source directory run the command:: + + make test + +It is also possible to generate test coverage reports using the Python coverage +tool. To do that execute:: + + make coverage + +To execute the Pylint code analysis tool run:: + + make check + +Running Pylint requires Python3 due to usage of pocket-lint. + + +Test Suite Architecture +------------------------ + +Pyparted test suite relies on several base classes listed below. All test +cases inherit from them. + +- :class:`unittest.TestCase` - the standard unit test class in Python. + Used only for base classes described below and for test cases which + don't need access to filesystems or disks; + + +- :class:`~tests.baseclass.RequiresDeviceNode` - base class for any test case + that requires a temporary device node; + +- :class:`~tests.baseclass.RequiresDevice` - base class for any test case that + requires a _ped.Device or parted.Device object first; + +- :class:`~tests.baseclass.RequiresFileSystem` - base class for any test case + that requires a filesystem on a device; + +- :class:`~tests.baseclass.RequiresDeviceAlignment`- base class for certain + alignment tests that require a _ped.Device; + +- :class:`~tests.baseclass.RequiresLabeledDevice` - base class for any test + case that requires a labeled device; + +- :class:`~tests.baseclass.RequiresDisk` - base class for any test case that + requires a _ped.Disk or parted.Disk; + +- :class:`~tests.baseclass.RequiresMount` - base class for any test case that + requires a filesystem made and mounted; + +- :class:`~tests.baseclass.RequiresPartition` - base class for any test case + that requires a _ped.Partition; + +- :class:`~tests.baseclass.RequiresDiskTypes` - base class for any test case + that requires a hash table of all _ped.DiskType objects available; + +- :class:`~tests.baseclass.BuildList` - base class for any test case that + requires a list being built via successive calls of some function. The + function must raise IndexError when there's no more output to add to the + return list. This class is most useful for all those _get_next methods. + It is used in combination with other base classes; + + +Test scenarios are defined inside the `runTest` method of each test class using +multiple assert statements. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/pylint/runpylint.py new/pyparted-3.11.1/tests/pylint/runpylint.py --- old/pyparted-3.10.7/tests/pylint/runpylint.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/pylint/runpylint.py 2017-06-26 17:20:05.000000000 +0200 @@ -9,12 +9,6 @@ def extraArgs(self): return ["--extension-pkg-whitelist", "_ped"] - @property - def pylintPlugins(self): - retval = super(PypartedLintConfig, self).pylintPlugins - retval.remove("pocketlint.checkers.eintr") - return retval - if __name__ == "__main__": conf = PypartedLintConfig() linter = PocketLinter(conf) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test__ped_geometry.py new/pyparted-3.11.1/tests/test__ped_geometry.py --- old/pyparted-3.10.7/tests/test__ped_geometry.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test__ped_geometry.py 2017-06-26 17:20:05.000000000 +0200 @@ -1,5 +1,5 @@ # -# Copyright (C) 2008-2011 Red Hat, Inc. +# Copyright (C) 2008-2016 Red Hat, Inc. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions of @@ -19,6 +19,7 @@ # import _ped +import six from tests.baseclass import RequiresDevice # One class per method, multiple tests per class. For these simple methods, @@ -374,4 +375,4 @@ lines = str(self.g).split('\n') self.assertEqual(lines[0], '_ped.Geometry instance --') self.assertEqual(lines[1], ' start: 10 end: 109 length: 100') - self.assertRegexpMatches(lines[2], '^ device: <_ped.Device object at .*') + six.assertRegex(self, lines[2], '^ device: <_ped.Device object at .*') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test__ped_partition.py new/pyparted-3.11.1/tests/test__ped_partition.py --- old/pyparted-3.10.7/tests/test__ped_partition.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test__ped_partition.py 2017-06-26 17:20:05.000000000 +0200 @@ -122,7 +122,7 @@ 'PARTITION_APPLE_TV_RECOVERY', 'PARTITION_BIOS_GRUB', 'PARTITION_DIAG', 'PARTITION_MSFT_DATA', 'PARTITION_IRST', - 'PARTITION_ESP']: + 'PARTITION_ESP', 'PARTITION_NONFS']: if not hasattr(_ped, f): continue attr = getattr(_ped, f) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test__ped_ped.py new/pyparted-3.11.1/tests/test__ped_ped.py --- old/pyparted-3.10.7/tests/test__ped_ped.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test__ped_ped.py 2017-06-26 17:20:05.000000000 +0200 @@ -41,7 +41,7 @@ 'PARTITION_APPLE_TV_RECOVERY', 'PARTITION_BIOS_GRUB', 'PARTITION_DIAG', 'PARTITION_MSFT_DATA', 'PARTITION_IRST', - 'PARTITION_ESP']: + 'PARTITION_ESP', 'PARTITION_NONFS']: if not hasattr(_ped, f): continue attr = getattr(_ped, f) @@ -54,7 +54,7 @@ def runTest(self): for f in ["boot", "root", "swap", "hidden", "raid", "lvm", "lba", "hp-service", "palo", "prep", "msftres", "bios_grub", - "msftdata", "irst", "esp"]: + "msftdata", "irst", "esp", "nonfs"]: self.assertNotEqual(_ped.partition_flag_get_by_name(f), "", "Could not get flag %s" % f) self.assertEqual(_ped.partition_flag_get_by_name("nosuchflag"), 0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test_parted_alignment.py new/pyparted-3.11.1/tests/test_parted_alignment.py --- old/pyparted-3.10.7/tests/test_parted_alignment.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test_parted_alignment.py 2017-06-26 17:20:05.000000000 +0200 @@ -141,21 +141,3 @@ def runTest(self): # TODO self.fail("Unimplemented test case.") - -# And then a suite to hold all the test cases for this module. -def makeSuite(): - suite = unittest.TestSuite() - suite.addTest(AlignmentNewTestCase()) - suite.addTest(AlignmentGetSetTestCase()) - suite.addTest(AlignmentIntersectTestCase()) - suite.addTest(AlignmentAlignUpTestCase()) - suite.addTest(AlignmentAlignDownTestCase()) - suite.addTest(AlignmentAlignNearestTestCase()) - suite.addTest(AlignmentIsAlignedTestCase()) - suite.addTest(AlignmentGetPedAlignmentTestCase()) - suite.addTest(AlignmentStrTestCase()) - return suite - -s = makeSuite() -if __name__ == "__main__": - unittest.main(defaultTest='s', verbosity=2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test_parted_constraint.py new/pyparted-3.11.1/tests/test_parted_constraint.py --- old/pyparted-3.10.7/tests/test_parted_constraint.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test_parted_constraint.py 2017-06-26 17:20:05.000000000 +0200 @@ -155,20 +155,3 @@ def runTest(self): # TODO self.fail("Unimplemented test case.") - -# And then a suite to hold all the test cases for this module. -def makeSuite(): - suite = unittest.TestSuite() - suite.addTest(ConstraintNewTestCase()) - suite.addTest(ConstraintGetSetTestCase()) - suite.addTest(ConstraintIntersectTestCase()) - suite.addTest(ConstraintSolveMaxTestCase()) - suite.addTest(ConstraintSolveNearestTestCase()) - suite.addTest(ConstraintIsSolutionTestCase()) - suite.addTest(ConstraintGetPedConstraintTestCase()) - suite.addTest(ConstraintStrTestCase()) - return suite - -s = makeSuite() -if __name__ == "__main__": - unittest.main(defaultTest='s', verbosity=2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test_parted_device.py new/pyparted-3.11.1/tests/test_parted_device.py --- old/pyparted-3.10.7/tests/test_parted_device.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test_parted_device.py 2017-06-26 17:20:05.000000000 +0200 @@ -155,34 +155,3 @@ def runTest(self): # TODO self.fail("Unimplemented test case.") - -# And then a suite to hold all the test cases for this module. -def makeSuite(): - suite = unittest.TestSuite() - suite.addTest(DeviceNewTestCase()) - suite.addTest(DeviceGetSetTestCase()) - suite.addTest(DeviceOpenTestCase()) - suite.addTest(DeviceCloseTestCase()) - suite.addTest(DeviceDestroyTestCase()) - suite.addTest(DeviceRemoveFromCacheTestCase()) - suite.addTest(DeviceBeginExternalAccessTestCase()) - suite.addTest(DeviceEndExternalAccessTestCase()) - suite.addTest(DeviceReadTestCase()) - suite.addTest(DeviceWriteTestCase()) - suite.addTest(DeviceSyncTestCase()) - suite.addTest(DeviceCheckTestCase()) - suite.addTest(DeviceStartSectorToCylinderTestCase()) - suite.addTest(DeviceEndSectorToCylinderTestCase()) - suite.addTest(DeviceStartCylinderToSectorTestCase()) - suite.addTest(DeviceEndCylinderToSectorTestCase()) - suite.addTest(DeviceGetSizeTestCase()) - suite.addTest(DeviceGetLengthTestCase()) - suite.addTest(DeviceGetSizeAsSectorsTestCase()) - suite.addTest(DeviceGetConstraintTestCase()) - suite.addTest(DeviceGetPedDeviceTestCase()) - suite.addTest(DeviceStrTestCase()) - return suite - -s = makeSuite() -if __name__ == "__main__": - unittest.main(defaultTest='s', verbosity=2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test_parted_disk.py new/pyparted-3.11.1/tests/test_parted_disk.py --- old/pyparted-3.10.7/tests/test_parted_disk.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test_parted_disk.py 2017-06-26 17:20:05.000000000 +0200 @@ -88,11 +88,19 @@ # TODO self.fail("Unimplemented test case.") -@unittest.skip("Unimplemented test case.") -class DiskAddPartitionTestCase(unittest.TestCase): +class DiskAddPartitionTestCase(RequiresDisk): + """ + addPartition should return True if partition is added successfully(even + without committing) + """ def runTest(self): - # TODO - self.fail("Unimplemented test case.") + self.disk.setFlag(parted.DISK_CYLINDER_ALIGNMENT) + + length = 100 + geom = parted.Geometry(self.device, start=100, length=length) + part = parted.Partition(self.disk, parted.PARTITION_NORMAL, geometry=geom) + constraint = parted.Constraint(exactGeom=geom) + self.assertTrue(self.disk.addPartition(part, constraint)) @unittest.skip("Unimplemented test case.") class DiskRemovePartitionTestCase(unittest.TestCase): @@ -142,17 +150,17 @@ # TODO self.fail("Unimplemented test case.") -@unittest.skip("Unimplemented test case.") -class DiskGetMaxLogicalPartitionsTestCase(unittest.TestCase): - def runTest(self): - # TODO - self.fail("Unimplemented test case.") - -@unittest.skip("Unimplemented test case.") -class DiskGetMaxSupportedPartitionCountTestCase(unittest.TestCase): +class DiskGetMaxSupportedPartitionCountTestCase(RequiresDisk): + """ + maxSupportedPartitionCount should return value 64, based on default + value MAX_NUM_PARTS(parted/libparted/arch/linux.c) applied if it cannot + find value in /sys/block/DEV/ext_range (RequiresDisk implies there is + no ext_range value). Also see testcase + DiskGetMaxSupportedPartitionCountTestCase in tests/test__ped_disk , + which tests value returned by source C function defined in module _ped + """ def runTest(self): - # TODO - self.fail("Unimplemented test case.") + self.assertEqual(self.disk.maxSupportedPartitionCount, 64) class DiskMaxPartitionLengthTestCase(RequiresDisk): def runTest(self): @@ -254,50 +262,3 @@ def runTest(self): # TODO self.fail("Unimplemented test case.") - -# And then a suite to hold all the test cases for this module. -def makeSuite(): - suite = unittest.TestSuite() - suite.addTest(DiskNewTestCase()) - suite.addTest(DiskGetSetTestCase()) - suite.addTest(DiskClobberTestCase()) - suite.addTest(DiskDuplicateTestCase()) - suite.addTest(DiskDestroyTestCase()) - suite.addTest(DiskCommitTestCase()) - suite.addTest(DiskCommitToDeviceTestCase()) - suite.addTest(DiskCommitToOSTestCase()) - suite.addTest(DiskCheckTestCase()) - suite.addTest(DiskSupportsFeatureTestCase()) - suite.addTest(DiskAddPartitionTestCase()) - suite.addTest(DiskRemovePartitionTestCase()) - suite.addTest(DiskDeletePartitionTestCase()) - suite.addTest(DiskDeleteAllPartitionsTestCase()) - suite.addTest(DiskSetPartitionGeometryTestCase()) - suite.addTest(DiskMaximizePartitionTestCase()) - suite.addTest(DiskCalculateMaxPartitionGeometryTestCase()) - suite.addTest(DiskMinimizeExtendedPartitionTestCase()) - suite.addTest(DiskGetPartitionBySectorTestCase()) - suite.addTest(DiskGetMaxLogicalPartitionsTestCase()) - suite.addTest(DiskGetMaxSupportedPartitionCountTestCase()) - suite.addTest(DiskMaxPartitionLengthTestCase()) - suite.addTest(DiskMaxPartitionStartSectorTestCase()) - suite.addTest(DiskGetFlagTestCase()) - suite.addTest(DiskSetFlagTestCase()) - suite.addTest(DiskUnsetFlagTestCase()) - suite.addTest(DiskIsFlagAvailableTestCase()) - suite.addTest(DiskGetExtendedPartitionTestCase()) - suite.addTest(DiskGetLogicalPartitionsTestCase()) - suite.addTest(DiskGetPrimaryPartitionsTestCase()) - suite.addTest(DiskGetRaidPartitionsTestCase()) - suite.addTest(DiskGetLVMPartitionsTestCase()) - suite.addTest(DiskGetFreeSpaceRegionsTestCase()) - suite.addTest(DiskGetFreeSpacePartitionsTestCase()) - suite.addTest(DiskGetFirstPartitionTestCase()) - suite.addTest(DiskGetPartitionByPathTestCase()) - suite.addTest(DiskGetPedDiskTestCase()) - suite.addTest(DiskStrTestCase()) - return suite - -s = makeSuite() -if __name__ == "__main__": - unittest.main(defaultTest='s', verbosity=2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test_parted_filesystem.py new/pyparted-3.11.1/tests/test_parted_filesystem.py --- old/pyparted-3.10.7/tests/test_parted_filesystem.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test_parted_filesystem.py 2017-06-26 17:20:05.000000000 +0200 @@ -48,16 +48,3 @@ def runTest(self): # TODO self.fail("Unimplemented test case.") - -# And then a suite to hold all the test cases for this module. -def makeSuite(): - suite = unittest.TestSuite() - suite.addTest(FileSystemNewTestCase()) - suite.addTest(FileSystemGetSetTestCase()) - suite.addTest(FileSystemGetPedFileSystemTestCase()) - suite.addTest(FileSystemStrTestCase()) - return suite - -s = makeSuite() -if __name__ == "__main__": - unittest.main(defaultTest='s', verbosity=2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test_parted_geometry.py new/pyparted-3.11.1/tests/test_parted_geometry.py --- old/pyparted-3.10.7/tests/test_parted_geometry.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test_parted_geometry.py 2017-06-26 17:20:05.000000000 +0200 @@ -125,28 +125,3 @@ def runTest(self): # TODO self.fail("Unimplemented test case.") - -# And then a suite to hold all the test cases for this module. -def makeSuite(): - suite = unittest.TestSuite() - suite.addTest(GeometryNewTestCase()) - suite.addTest(GeometryGetSetTestCase()) - suite.addTest(GeometryCheckTestCase()) - suite.addTest(GeometryContainsTestCase()) - suite.addTest(GeometryContainsSectorTestCase()) - suite.addTest(GeometryEqualTestCase()) - suite.addTest(GeometryGetSizeTestCase()) - suite.addTest(GeometryGetLengthTestCase()) - suite.addTest(GeometryIntersectTestCase()) - suite.addTest(GeometryMapTestCase()) - suite.addTest(GeometryOverlapsWithTestCase()) - suite.addTest(GeometryReadTestCase()) - suite.addTest(GeometrySyncTestCase()) - suite.addTest(GeometryWriteTestCase()) - suite.addTest(GeometryGetPedGeometryTestCase()) - suite.addTest(GeometryStrTestCase()) - return suite - -s = makeSuite() -if __name__ == "__main__": - unittest.main(defaultTest='s', verbosity=2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test_parted_parted.py new/pyparted-3.11.1/tests/test_parted_parted.py --- old/pyparted-3.10.7/tests/test_parted_parted.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test_parted_parted.py 2017-06-26 17:20:05.000000000 +0200 @@ -44,6 +44,7 @@ self.assertRaises(SyntaxError, parted.sizeToSectors, 9, "yb", 1) self.assertEqual(int(parted.sizeToSectors(7777.0, "B", 512)), parted.sizeToSectors(7777.0, "B", 512)) + self.assertEqual(parted.sizeToSectors(1000, "B", 512), 2) class GetLabelsTestCase(unittest.TestCase): def runTest(self): @@ -141,23 +142,3 @@ ver = parted.version() self.assertEqual(ver['libparted'], _ped.libparted_version()) self.assertEqual(ver['pyparted'], _ped.pyparted_version()) - -# And then a suite to hold all the test cases for this module. -def makeSuite(): - suite = unittest.TestSuite() - suite.addTest(FormatBytesTestCase()) - suite.addTest(BytesToSectorsTestCase()) - suite.addTest(GetLabelsTestCase()) - suite.addTest(GetDeviceTestCase()) - suite.addTest(GetAllDevicesTestCase()) - suite.addTest(ProbeForSpecificFileSystemTestCase()) - suite.addTest(ProbeFileSystemTestCase()) - suite.addTest(FreshDiskTestCase()) - suite.addTest(IsAlignToCylindersTestCase()) - suite.addTest(ToggleAlignToCylindersTestCase()) - suite.addTest(VersionTestCase()) - return suite - -s = makeSuite() -if __name__ == "__main__": - unittest.main(defaultTest='s', verbosity=2) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyparted-3.10.7/tests/test_parted_partition.py new/pyparted-3.11.1/tests/test_parted_partition.py --- old/pyparted-3.10.7/tests/test_parted_partition.py 2015-08-27 21:59:22.000000000 +0200 +++ new/pyparted-3.11.1/tests/test_parted_partition.py 2017-06-26 17:20:05.000000000 +0200 @@ -28,35 +28,158 @@ # One class per method, multiple tests per class. For these simple methods, # that seems like good organization. More complicated methods may require # multiple classes and their own test suite. -@unittest.skip("Unimplemented test case.") -class PartitionNewTestCase(unittest.TestCase): - def runTest(self): - # TODO - self.fail("Unimplemented test case.") -@unittest.skip("Unimplemented test case.") -class PartitionGetSetTestCase(unittest.TestCase): +class PartitionNewTestCase(RequiresDisk): + """ + PartitionNew tests if parted.Partition: + 1) raises user defined exception if called without arguments + 2) if parted.Partition is instantiable with argument fs + 3) if parted.Partition is instantiable without argument fs + """ + def setUp(self): + super(PartitionNewTestCase, self).setUp() + self.geom = parted.Geometry(self.device, start=100, length=100) + self.fs = parted.FileSystem(type='ext2', geometry=self.geom) + self.part = parted.Partition(self.disk, parted.PARTITION_NORMAL, + geometry=self.geom, fs=self.fs) + + def runTest(self): + # Check that not passing args to parted.Partition.__init__ is caught. + with self.assertRaises((parted.PartitionException,)): + parted.Partition() + + self.assertIsInstance(self.part, parted.Partition) + # You don't need to pass a filesystem type at all, since this partition + # might be FREESPACE or METADATA. + part_nofs = parted.Partition(self.disk, parted.PARTITION_NORMAL, + geometry=self.geom) + self.assertIsInstance(part_nofs, parted.Partition) + +class PartitionGetSetTestCase(PartitionNewTestCase): + """ + PartitionGetSet tests "part" instance + of class parted.Partition(created in baseclass) + for basic get and set operations on its attributes. + """ + def runTest(self): + # Test that passing the kwargs to __init__ works. + self.assertEqual(self.part.disk, self.disk) + self.assertIsInstance(self.part.geometry, parted.Geometry) + self.assertEqual(self.part.type, parted.PARTITION_NORMAL) + self.assertEqual(self.part.fileSystem.type, "ext2") + + # Test that setting the RW attributes directly works. + self.part.type = parted.PARTITION_EXTENDED + self.assertEqual(self.part.type, parted.PARTITION_EXTENDED) + + # Test that setting the RO attributes directly doesn't work. + exn = (AttributeError, TypeError) + with self.assertRaises(exn): + self.part.number = 1 + with self.assertRaises(exn): + self.part.active = True + with self.assertRaises(exn): + self.part.name = "blah" + with self.assertRaises(exn): + self.part.type = "blah" + with self.assertRaises(exn): + self.part.disk = self.disk + + # Check that looking for invalid attributes fails properly. + with self.assertRaises((AttributeError)): + print(self.part.blah) + +class PartitionSetFlagTestCase(PartitionNewTestCase): + """ + Method setFlag should return True, if flag was set to "on" state. + Next few flag testcases will inherit from setUp. + This testcase checks if method setFlag returns: + 1)correct bool when state of BOOT and RAID flags is set to "on" + on partition. + 2)raises user defined exception on unavailable flag + See parted/include/parted/disk.in.h for flag numbers. + Partition flags are dependent on disklabel. In this case msdos label is + used, see parted library libparted/labels/dos.c for flags availability. + """ + def setUp(self): + super(PartitionSetFlagTestCase, self).setUp() + self.neg_msg = "Method returns unexpected bool value" + self.flag_set = self.part.setFlag(1) + self.flag_set1 = self.part.setFlag(5) + + def runTest(self): + self.assertTrue(self.flag_set, self.neg_msg) + self.assertTrue(self.flag_set1, self.neg_msg) + with self.assertRaises((parted.PartitionException,)): + self.part.setFlag(2) + +class PartitionGetFlagTestCase(PartitionSetFlagTestCase): + """ + Method getFlag should return correct bool value depending on flag + setting(flag is off=>False; on=>True). + This testcase checks if method getFlag returns: + 1)correct bools when checks state of BOOT(on), RAID(on) and LVM(off) + flags. + """ + def runTest(self): + self.assertTrue(self.part.getFlag(1), self.neg_msg) + self.assertTrue(self.part.getFlag(5), self.neg_msg) + self.assertFalse(self.part.getFlag(6), self.neg_msg) + +class PartitionUnsetFlagTestCase(PartitionSetFlagTestCase): + """ + Method unsetFlag should set flag to "off" state and return True on + success. PartitionException should be raised on error. + This testcase checks if method unsetFlag returns: + 1)correct bool value when flag is unset and if flag is in state 'off' + 2)raises user defined exception on unavailable flag + """ + def runTest(self): + self.assertTrue(self.part.unsetFlag(1), self.neg_msg) + self.assertFalse(self.part.getFlag(1), self.neg_msg) + + with self.assertRaises((parted.PartitionException,)): + self.part.unsetFlag(2) + +class PartitionIsFlagAvailableTestCase(PartitionNewTestCase): + ''' + Method isFlagAvailable should return bool value whenever flag is + available according to chosen disk label setting and disk proportions + itself. + This testcase checks if method isFlagAvailable returns: + 1)bool value without traceback + 2)false on nonexistent flag + 3)raises user defined exception when called on inactive partition + ''' + def runTest(self): + for f in ['PARTITION_BOOT', 'PARTITION_ROOT', 'PARTITION_SWAP', + 'PARTITION_HIDDEN', 'PARTITION_RAID', 'PARTITION_LVM', + 'PARTITION_LBA', 'PARTITION_HPSERVICE', + 'PARTITION_PALO', 'PARTITION_PREP', + 'PARTITION_MSFT_RESERVED', + 'PARTITION_APPLE_TV_RECOVERY', + 'PARTITION_BIOS_GRUB', 'PARTITION_DIAG', + 'PARTITION_MSFT_DATA', 'PARTITION_IRST', + 'PARTITION_ESP', 'PARTITION_NONFS']: + if not hasattr(parted, f): + continue + attr = getattr(parted, f) + self.assertIsInstance(self.part.isFlagAvailable(attr), bool) + + self.assertFalse(self.part.isFlagAvailable(1000)) + + with self.assertRaises((parted.PartitionException,)): + self.part = parted.Partition(self.disk, parted.PARTITION_FREESPACE, + geometry=self.geom) + self.part.isFlagAvailable(parted.PARTITION_BOOT) + +class PartitionGetFlagsAsStringTestCase(PartitionSetFlagTestCase): + ''' + Method getFlagsAsString should return all flags which are in state "on" + as comma separated list. + ''' def runTest(self): - # TODO - self.fail("Unimplemented test case.") - -@unittest.skip("Unimplemented test case.") -class PartitionGetFlagTestCase(unittest.TestCase): - def runTest(self): - # TODO - self.fail("Unimplemented test case.") - -@unittest.skip("Unimplemented test case.") -class PartitionSetFlagTestCase(unittest.TestCase): - def runTest(self): - # TODO - self.fail("Unimplemented test case.") - -@unittest.skip("Unimplemented test case.") -class PartitionUnsetFlagTestCase(unittest.TestCase): - def runTest(self): - # TODO - self.fail("Unimplemented test case.") + self.assertEqual(self.part.getFlagsAsString(), 'boot, raid') @unittest.skip("Unimplemented test case.") class PartitionGetMaxGeometryTestCase(unittest.TestCase): @@ -65,12 +188,6 @@ self.fail("Unimplemented test case.") @unittest.skip("Unimplemented test case.") -class PartitionIsFlagAvailableTestCase(unittest.TestCase): - def runTest(self): - # TODO - self.fail("Unimplemented test case.") - -@unittest.skip("Unimplemented test case.") class PartitionNextPartitionTestCase(unittest.TestCase): def runTest(self): # TODO @@ -96,12 +213,6 @@ self.assertEqual(part.getLength(), length) @unittest.skip("Unimplemented test case.") -class PartitionGetFlagsAsStringTestCase(unittest.TestCase): - def runTest(self): - # TODO - self.fail("Unimplemented test case.") - -@unittest.skip("Unimplemented test case.") class PartitionGetMaxAvailableSizeTestCase(unittest.TestCase): def runTest(self): # TODO @@ -124,27 +235,3 @@ def runTest(self): # TODO self.fail("Unimplemented test case.") - -# And then a suite to hold all the test cases for this module. -def makeSuite(): - suite = unittest.TestSuite() - suite.addTest(PartitionNewTestCase()) - suite.addTest(PartitionGetSetTestCase()) - suite.addTest(PartitionGetFlagTestCase()) - suite.addTest(PartitionSetFlagTestCase()) - suite.addTest(PartitionUnsetFlagTestCase()) - suite.addTest(PartitionGetMaxGeometryTestCase()) - suite.addTest(PartitionIsFlagAvailableTestCase()) - suite.addTest(PartitionNextPartitionTestCase()) - suite.addTest(PartitionGetSizeTestCase()) - suite.addTest(PartitionGetLengthTestCase()) - suite.addTest(PartitionGetFlagsAsStringTestCase()) - suite.addTest(PartitionGetMaxAvailableSizeTestCase()) - suite.addTest(PartitionGetDeviceNodeNameTestCase()) - suite.addTest(PartitionGetPedPartitionTestCase()) - suite.addTest(PartitionStrTestCase()) - return suite - -s = makeSuite() -if __name__ == "__main__": - unittest.main(defaultTest='s', verbosity=2) ++++++ python-parted-featurestest.patch ++++++ Index: pyparted-3.11.1/tests/test__ped_disktype.py =================================================================== --- pyparted-3.11.1.orig/tests/test__ped_disktype.py +++ pyparted-3.11.1/tests/test__ped_disktype.py @@ -80,7 +80,7 @@ class DiskTypeStrTestCase(RequiresDiskTy self.assertEqual(str(self.disktype['sun']), '_ped.DiskType instance --\n name: sun features: 0') self.assertEqual(str(self.disktype['amiga']), '_ped.DiskType instance --\n name: amiga features: 2') self.assertEqual(str(self.disktype['gpt']), '_ped.DiskType instance --\n name: gpt features: 2') - self.assertEqual(str(self.disktype['mac']), '_ped.DiskType instance --\n name: mac features: 2') + self.assertEqual(str(self.disktype['mac']), '_ped.DiskType instance --\n name: mac features: 6') self.assertEqual(str(self.disktype['bsd']), '_ped.DiskType instance --\n name: bsd features: 0') self.assertEqual(str(self.disktype['pc98']), '_ped.DiskType instance --\n name: pc98 features: 2') self.assertEqual(str(self.disktype['loop']), '_ped.DiskType instance --\n name: loop features: 0') Index: pyparted-3.11.1/tests/test_parted_partition.py =================================================================== --- pyparted-3.11.1.orig/tests/test_parted_partition.py +++ pyparted-3.11.1/tests/test_parted_partition.py @@ -179,7 +179,7 @@ class PartitionGetFlagsAsStringTestCase( as comma separated list. ''' def runTest(self): - self.assertEqual(self.part.getFlagsAsString(), 'boot, raid') + self.assertEqual(self.part.getFlagsAsString(), 'boot, raid, type') @unittest.skip("Unimplemented test case.") class PartitionGetMaxGeometryTestCase(unittest.TestCase): ++++++ python-parted-parted-binary.patch ++++++ Index: pyparted-3.11.1/tests/baseclass.py =================================================================== --- pyparted-3.11.1.orig/tests/baseclass.py +++ pyparted-3.11.1/tests/baseclass.py @@ -68,7 +68,7 @@ class RequiresFileSystem(unittest.TestCa os.write(fd, b"0") f.close() - os.system("mke2fs -F -q %s" % (self.path,)) + os.system("/usr/sbin/mke2fs -F -q %s" % (self.path,)) self._device = _ped.device_get(self.path) self._geometry = _ped.Geometry(self._device, 0, self._device.length - 1) @@ -133,7 +133,7 @@ class RequiresDeviceAlignment(RequiresDe class RequiresLabeledDevice(RequiresDevice): def setUp(self): RequiresDevice.setUp(self) - os.system("parted -s %s mklabel msdos" % (self.path,)) + os.system("/usr/sbin/parted -s %s mklabel msdos" % (self.path,)) # Base class for any test case that requires a _ped.Disk or parted.Disk. class RequiresDisk(RequiresDevice): @@ -150,7 +150,7 @@ class RequiresMount(RequiresDevice): self.mountpoint = None def mkfs(self): - os.system("mkfs.ext2 -F -q %s" % self.path) + os.system("/usr/sbin/mkfs.ext2 -F -q %s" % self.path) def doMount(self): self.mountpoint = tempfile.mkdtemp() ++++++ python-parted-unittests.patch ++++++ >From 52762a217fdc702e3f8ed869d1d8ccf30babed05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20=27sil2100=27=20Zemczak?= <lukasz.zemc...@ubuntu.com> Date: Mon, 17 Jul 2017 12:36:01 +0200 Subject: [PATCH] _ped's *_flag_get_name methods now throw a PartedException instead of ValueError on unsupported flags. --- tests/test__ped_ped.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test__ped_ped.py b/tests/test__ped_ped.py index 79046ab..e7ce116 100755 --- a/tests/test__ped_ped.py +++ b/tests/test__ped_ped.py @@ -48,7 +48,7 @@ def runTest(self): self.assertNotEqual(_ped.partition_flag_get_name(attr), "", "Could not get name for flag _ped.%s" % f) self.assertRaises(ValueError, _ped.partition_flag_get_name, -1) - self.assertRaises(ValueError, _ped.partition_flag_get_name, 1000) + self.assertRaises(_ped.PartedException, _ped.partition_flag_get_name, 1000) class PartitionFlagGetByNameTestCase(unittest.TestCase): def runTest(self): @@ -82,7 +82,7 @@ def runTest(self): self.assertNotEqual(_ped.disk_flag_get_name(f), "", "Could not get name for flag %s" % f) self.assertRaises(ValueError, _ped.disk_flag_get_name, -1) - self.assertRaises(ValueError, _ped.disk_flag_get_name, 1000) + self.assertRaises(_ped.PartedException, _ped.disk_flag_get_name, 1000) class DiskFlagGetByNameTestCase(unittest.TestCase): def runTest(self):