1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-24 19:22:13 +01:00

- raise OscIOError instead of IOError (adjusted testcases)

This commit is contained in:
Marcus Huewe 2010-09-02 10:23:37 +02:00
parent 7145ecf0c9
commit b718669685
7 changed files with 20 additions and 20 deletions

View File

@ -801,7 +801,7 @@ class Package:
def addfile(self, n):
if not os.path.exists(os.path.join(self.absdir, n)):
raise IOError('error: file \'%s\' does not exist' % n)
raise oscerr.OscIOError(None, 'error: file \'%s\' does not exist' % n)
if n in self.to_be_deleted:
self.to_be_deleted.remove(n)
# self.delete_storefile(n)
@ -1331,7 +1331,7 @@ class Package:
'.osc/ dir) into the new package wc. Please file a bug.' % n)
else:
# this case shouldn't happen (except there was a typo in the filename etc.)
raise IOError('osc: \'%s\' is not under version control' % n)
raise oscerr.OscIOError(None, 'osc: \'%s\' is not under version control' % n)
return state
@ -1398,7 +1398,7 @@ class Package:
elif fname in self.filenamelist:
kept.append(self.findfilebyname(fname))
elif not ignoreUnversioned:
raise IOError('file \'%s\' is not under version control' % fname)
raise oscerr.OscIOError(None, 'file \'%s\' is not under version control' % fname)
else:
fm = show_files_meta(self.apiurl, self.prjname, self.name, revision=revision)
root = ET.fromstring(fm)
@ -1842,9 +1842,9 @@ rev: %s
def revert(self, filename):
if not filename in self.filenamelist and not filename in self.to_be_added:
raise IOError('file \'%s\' is not under version control' % filename)
raise oscerr.OscIOError(None, 'file \'%s\' is not under version control' % filename)
elif filename in self.skipped:
raise IOError('file \'%s\' is marked as skipped and cannot be reverted')
raise oscerr.OscIOError(None, 'file \'%s\' is marked as skipped and cannot be reverted')
if filename in self.filenamelist and not os.path.exists(os.path.join(self.storedir, filename)):
raise oscerr.PackageInternalError('file \'%s\' is listed in filenamelist but no storefile exists' % filename)
state = self.status(filename)
@ -1866,9 +1866,9 @@ rev: %s
if not os.path.exists(dir):
os.mkdir(dir)
elif not os.path.isdir(dir):
raise IOError('error: \'%s\' is no directory' % dir)
raise oscerr.OscIOError(None, 'error: \'%s\' is no directory' % dir)
if os.path.exists(os.path.join(dir, store)):
raise IOError('error: \'%s\' is already an initialized osc working copy' % dir)
raise oscerr.OscIOError(None, 'error: \'%s\' is already an initialized osc working copy' % dir)
else:
os.mkdir(os.path.join(dir, store))
store_write_project(dir, project)
@ -2867,7 +2867,7 @@ def read_meta_from_spec(specfile, *args):
"""
if not os.path.isfile(specfile):
raise IOError('\'%s\' is not a regular file' % specfile)
raise oscerr.OscIOError(None, '\'%s\' is not a regular file' % specfile)
try:
lines = codecs.open(specfile, 'r', locale.getpreferredencoding()).readlines()

View File

@ -77,7 +77,7 @@ class TestAddFiles(OscTestCase):
"""add a non existent file"""
self._change_to_pkg('simple')
p = osc.core.Package('.')
self.assertRaises(IOError, p.addfile, 'doesnotexist')
self.assertRaises(osc.oscerr.OscIOError, p.addfile, 'doesnotexist')
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
if __name__ == '__main__':

View File

@ -111,8 +111,8 @@ class TestCommit(OscTestCase):
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_deleted')))
self.assertFalse(os.path.exists(os.path.join('.osc', 'foo')))
self.assertFalse(os.path.exists(os.path.join('.osc', 'merge')))
self.assertRaises(IOError, p.status, 'foo')
self.assertRaises(IOError, p.status, 'merge')
self.assertRaises(osc.oscerr.OscIOError, p.status, 'foo')
self.assertRaises(osc.oscerr.OscIOError, p.status, 'merge')
self._check_status(p, 'add', ' ')
self._check_status(p, 'add2', ' ')
self._check_status(p, 'nochange', ' ')
@ -140,7 +140,7 @@ class TestCommit(OscTestCase):
self._check_status(p, 'merge', 'D')
self._check_status(p, 'add', ' ')
self._check_status(p, 'nochange', ' ')
self.assertRaises(IOError, p.status, 'foo')
self.assertRaises(osc.oscerr.OscIOError, p.status, 'foo')
@GET('http://localhost/source/osctest/simple?rev=latest', file='testSimple_filesremote')
@PUT('http://localhost/source/osctest/simple/nochange?rev=upload', exp='This file didn\'t change but\nis modified.\n',

View File

@ -98,7 +98,7 @@ class TestDeleteFiles(OscTestCase):
self.__check_ret(ret, True, '?')
self.assertFalse(os.path.exists('toadd2'))
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_deleted')))
self.assertRaises(IOError, p.status, 'toadd2')
self.assertRaises(osc.oscerr.OscIOError, p.status, 'toadd2')
def testDeleteAddedForce(self):
"""delete an added file ('toadd1') from the wc (with force)"""
@ -109,7 +109,7 @@ class TestDeleteFiles(OscTestCase):
self.assertFalse(os.path.exists('toadd1'))
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_deleted')))
self.assertFalse(os.path.exists(os.path.join('.osc', '_to_be_added')))
self.assertRaises(IOError, p.status, 'toadd1')
self.assertRaises(osc.oscerr.OscIOError, p.status, 'toadd1')
def testDeleteReplacedForce(self):
"""delete an added file ('merge') from the wc (with force)"""

View File

@ -113,7 +113,7 @@ class TestDiffFiles(OscTestCase):
self._change_to_pkg('simple')
p = osc.core.Package('.')
p.todo = ['toadd2']
self.assertRaises(IOError, self.__check_diff, p, '', None)
self.assertRaises(osc.oscerr.OscIOError, self.__check_diff, p, '', None)
def testDiffMultipleFiles(self):
"""diff multiple files"""

View File

@ -75,14 +75,14 @@ class TestInitPackage(OscTestCase):
pac_dir = os.path.join(self.tmpdir, 'testpkg')
os.mkdir(pac_dir)
os.mkdir(os.path.join(pac_dir, osc.core.store))
self.assertRaises(IOError, osc.core.Package.init_package, 'http://localhost', 'osctest', 'testpkg', pac_dir)
self.assertRaises(osc.oscerr.OscIOError, osc.core.Package.init_package, 'http://localhost', 'osctest', 'testpkg', pac_dir)
def test_dirIsFile(self):
"""initialize a package dir (dir is a file)"""
pac_dir = os.path.join(self.tmpdir, 'testpkg')
os.mkdir(pac_dir)
open(os.path.join(pac_dir, osc.core.store), 'w').write('foo\n')
self.assertRaises(IOError, osc.core.Package.init_package, 'http://localhost', 'osctest', 'testpkg', pac_dir)
self.assertRaises(osc.oscerr.OscIOError, osc.core.Package.init_package, 'http://localhost', 'osctest', 'testpkg', pac_dir)
if __name__ == '__main__':
import unittest

View File

@ -18,7 +18,7 @@ class TestRevertFiles(OscTestCase):
"""revert an unchanged file (state == ' ')"""
self._change_to_pkg('simple')
p = osc.core.Package('.')
self.assertRaises(IOError, p.revert, 'toadd2')
self.assertRaises(osc.oscerr.OscIOError, p.revert, 'toadd2')
self._check_status(p, 'toadd2', '?')
def testRevertModified(self):
@ -61,7 +61,7 @@ class TestRevertFiles(OscTestCase):
p = osc.core.Package('.')
p.revert('addedmissing')
self._check_addlist('toadd1\nreplaced\n')
self.assertRaises(IOError, p.status, 'addedmissing')
self.assertRaises(osc.oscerr.OscIOError, p.status, 'addedmissing')
def testRevertReplaced(self):
"""revert a replaced (state == 'R') file"""
@ -85,7 +85,7 @@ class TestRevertFiles(OscTestCase):
"""revert a skipped file"""
self._change_to_pkg('simple')
p = osc.core.Package('.')
self.assertRaises(IOError, p.revert, 'skipped')
self.assertRaises(osc.oscerr.OscIOError, p.revert, 'skipped')
def __check_file(self, fname):
storefile = os.path.join('.osc', fname)