diff options
77 files changed, 319 insertions, 319 deletions
diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/__init__.py diff --git a/tests/cache/__init__.py b/tests/cache/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/cache/__init__.py diff --git a/tests/cache/test_base.py b/tests/cache/test_base.py index abe54bee..3ed454dd 100644 --- a/tests/cache/test_base.py +++ b/tests/cache/test_base.py @@ -33,7 +33,7 @@ class DictCache(base): # Protected dict's come back by default, but are a minor # pita to deal with for this code- thus we convert back. # Additionally, we drop any chksum info in the process. - d = dict(base.__getitem__(self, cpv).iteritems()) + d = dict(base.__getitem__(self, cpv).items()) d.pop('_%s_' % self.chf_type, None) return d @@ -50,8 +50,8 @@ class DictCache(base): def __contains__(self, cpv): return cpv in self._data - def iterkeys(self): - return self._data.iterkeys() + def keys(self): + return iter(self._data.keys()) class DictCacheBulk(bulk): @@ -80,6 +80,9 @@ class DictCacheBulk(bulk): data['_chf_'] = _chf_obj return bulk.__setitem__(self, cpv, data) + def keys(self): + return iter(self._data.keys()) + class BaseTest(TestCase): @@ -106,8 +109,8 @@ class BaseTest(TestCase): del self.cache['foon'] self.assertRaises(KeyError, operator.getitem, self.cache, 'foon') - self.assertTrue(self.cache.has_key('spork')) - self.assertFalse(self.cache.has_key('foon')) + self.assertTrue('spork' in self.cache) + self.assertFalse('foon' in self.cache) self.cache['empty'] = {'foo': ''} self.assertEqual({}, self.cache['empty']) @@ -126,7 +129,7 @@ class BaseTest(TestCase): 'spork\t1\tfoon\t2', 'foon\t2\tspork\t1']) self.assertEqual( - sorted([('foon', (('mtime', 2L),)), ('spork', (('mtime', 1L),))]), + sorted([('foon', (('mtime', 2),)), ('spork', (('mtime', 1),))]), sorted(self.cache['spork']['_eclasses_'])) def test_readonly(self): @@ -192,4 +195,4 @@ class TestBulk(BaseTest): db = self.get_db() # write a key outside of known keys db["dar"] = {"foo2":"dar"} - self.assertEqual(db["dar"].items(), []) + self.assertEqual(list(db["dar"].items()), []) diff --git a/tests/cache/test_flat_hash.py b/tests/cache/test_flat_hash.py index 84900ee8..20c2dcdf 100644 --- a/tests/cache/test_flat_hash.py +++ b/tests/cache/test_flat_hash.py @@ -4,7 +4,8 @@ from snakeoil.test.mixins import TempDirMixin from pkgcore.cache import flat_hash -from pkgcore.test.cache import util, test_base +from tests.cache import test_base +from tests.cache.test_util import GenericCacheMixin class db(flat_hash.database): @@ -14,12 +15,12 @@ class db(flat_hash.database): return flat_hash.database.__setitem__(self, cpv, data) def __getitem__(self, cpv): - d = dict(flat_hash.database.__getitem__(self, cpv).iteritems()) + d = dict(flat_hash.database.__getitem__(self, cpv).items()) d.pop('_%s_' % self.chf_type, None) return d -class TestFlatHash(util.GenericCacheMixin, TempDirMixin): +class TestFlatHash(GenericCacheMixin, TempDirMixin): def get_db(self, readonly=False): return db(self.dir, diff --git a/tests/cache/test_util.py b/tests/cache/test_util.py index 5dfe63dd..afe6a65b 100644 --- a/tests/cache/test_util.py +++ b/tests/cache/test_util.py @@ -4,7 +4,6 @@ from snakeoil.chksum import LazilyHashedPath from pkgcore.cache import errors -from snakeoil.test import TestCase generic_data = \ ("sys-libs/libtrash-2.4", @@ -22,17 +21,17 @@ generic_data = \ ('SRC_URI', 'http://pages.stern.nyu.edu/~marriaga/software/blah.tgz'), ('_eclasses_', { - 'toolchain-funcs': LazilyHashedPath('/var/gentoo/repos/gentoo/eclass', mtime=1155996352L), - 'multilib': LazilyHashedPath('/var/gentoo/repos/gentoo/eclass', mtime=1156014349L), - 'eutils': LazilyHashedPath('/var/gentoo/repos/gentoo/eclass', mtime=1155996352L), - 'portability': LazilyHashedPath('/var/gentoo/repos/gentoo/eclass', mtime=1141850196L) + 'toolchain-funcs': LazilyHashedPath('/var/gentoo/repos/gentoo/eclass', mtime=1155996352), + 'multilib': LazilyHashedPath('/var/gentoo/repos/gentoo/eclass', mtime=1156014349), + 'eutils': LazilyHashedPath('/var/gentoo/repos/gentoo/eclass', mtime=1155996352), + 'portability': LazilyHashedPath('/var/gentoo/repos/gentoo/eclass', mtime=1141850196) } ), ('_mtime_', 1000), ), ) -class GenericCacheMixin(TestCase): +class GenericCacheMixin(object): cache_keys = ("DEPENDS", "RDEPEND", "EAPI", "HOMEPAGE", "KEYWORDS", "LICENSE", "PDEPEND", "RESTRICT", "SLOT", "SRC_URI", @@ -62,4 +61,3 @@ class GenericCacheMixin(TestCase): for key, raw_data in self.test_data: d = dict(raw_data) db[key] = d - diff --git a/tests/config/__init__.py b/tests/config/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/config/__init__.py diff --git a/tests/config/test_basics.py b/tests/config/test_basics.py index e3be61b8..41e74722 100644 --- a/tests/config/test_basics.py +++ b/tests/config/test_basics.py @@ -43,7 +43,7 @@ def nonopt(one, two): def alltypes(alist=(), astr='astr', abool=True, aref=object(), anint=3, - along=long(3)): + along=int(3)): """Function taking lots of kinds of args.""" @@ -241,7 +241,7 @@ class DictConfigSectionTest(TestCase): section = basics.DictConfigSection(convert, {'list': [1, 2]}) self.assertFalse('foo' in section) self.assertTrue('list' in section) - self.assertEqual(['list'], section.keys()) + self.assertEqual(['list'], list(section.keys())) self.assertEqual( (None, [1, 2], 'spoon'), section.render_value(None, 'list', 'spoon')) @@ -269,7 +269,7 @@ class FakeIncrementalDictConfigSectionTest(TestCase): self._convert, {'list': [1, 2]}) self.assertFalse('foo' in section) self.assertTrue('list' in section) - self.assertEqual(['list'], section.keys()) + self.assertEqual(['list'], list(section.keys())) self.assertRaises( errors.ConfigurationError, basics.FakeIncrementalDictConfigSection( @@ -329,7 +329,7 @@ class FakeIncrementalDictConfigSectionTest(TestCase): self.assertEqual( ('list', [ ['whatever'], - ['pkgcore.test.config.test_basics.asis'], + ['tests.config.test_basics.asis'], None]), section.render_value(manager, 'strlist', 'repr')) self.assertRaises( @@ -341,26 +341,26 @@ class ConvertStringTest(TestCase): def test_render_value(self): source = { - 'str': 'pkgcore.test', + 'str': 'tests', 'bool': 'yes', 'list': '0 1 2', - 'callable': 'pkgcore.test.config.test_basics.passthrough', + 'callable': 'tests.config.test_basics.passthrough', } destination = { - 'str': 'pkgcore.test', + 'str': 'tests', 'bool': True, 'list': ['0', '1', '2'], 'callable': passthrough, } # valid gets - for typename, value in destination.iteritems(): + for typename, value in destination.items(): self.assertEqual( value, basics.convert_string(None, source[typename], typename)) # reprs - for typename, value in source.iteritems(): + for typename, value in source.items(): self.assertEqual( ('str', value), basics.convert_string(None, source[typename], 'repr')) @@ -423,7 +423,7 @@ class ConvertStringTest(TestCase): class ConvertAsIsTest(TestCase): source = { - 'str': 'pkgcore.test', + 'str': 'tests', 'bool': True, 'list': ['0', '1', '2'], 'callable': passthrough, @@ -431,7 +431,7 @@ class ConvertAsIsTest(TestCase): def test_render_value(self): # try all combinations - for arg, value in self.source.iteritems(): + for arg, value in self.source.items(): for typename in self.source: if arg == typename: self.assertEqual( @@ -442,7 +442,7 @@ class ConvertAsIsTest(TestCase): basics.convert_asis, None, value, typename) def test_repr(self): - for typename, value in self.source.iteritems(): + for typename, value in self.source.items(): self.assertEqual( (typename, value), basics.convert_asis(None, value, 'repr')) diff --git a/tests/config/test_central.py b/tests/config/test_central.py index ac1399c5..d5d2897b 100644 --- a/tests/config/test_central.py +++ b/tests/config/test_central.py @@ -63,7 +63,7 @@ class ConfigManagerTest(TestCase): 'barinst': basics.HardCodedConfigSection({'class': drawer}), }]) self.assertEqual(['barinst', 'fooinst'], sorted(manager.sections())) - self.assertEqual(manager.objects.drawer.keys(), ['barinst']) + self.assertEqual(list(manager.objects.drawer.keys()), ['barinst']) self.assertEqual(manager.objects.drawer, {'barinst': (None, None)}) def test_contains(self): @@ -87,7 +87,7 @@ class ConfigManagerTest(TestCase): }]) self.check_error( "Collapsing section named 'rsync repo':\n" - "type pkgcore.test.config.test_central.repo needs settings for " + "type tests.config.test_central.repo needs settings for " "'cache'", self.get_config_obj, manager, 'repo', 'rsync repo') @@ -152,7 +152,7 @@ class ConfigManagerTest(TestCase): self.check_error( "Failed instantiating section 'myrepo':\n" "'No object returned' instantiating " - "pkgcore.test.config.test_central.noop", + "tests.config.test_central.noop", manager.collapse_named_section('myrepo').instantiate) def test_not_callable(self): @@ -176,7 +176,7 @@ class ConfigManagerTest(TestCase): }]) self.check_error( "Failed instantiating section 'myrepo':\n" - "Failed instantiating section 'myrepo': exception caught from 'pkgcore.test.config.test_central.myrepo':\n" + "Failed instantiating section 'myrepo': exception caught from 'tests.config.test_central.myrepo':\n" "I raised", self.get_config_obj, manager, 'myrepo', 'myrepo') @@ -188,7 +188,7 @@ class ConfigManagerTest(TestCase): }]) self.check_error( "Failed instantiating section 'myrepo':\n" - "Failed instantiating section 'myrepo': exception caught from 'pkgcore.test.config.test_central.myrepo':\n" + "Failed instantiating section 'myrepo': exception caught from 'tests.config.test_central.myrepo':\n" "I raised", self.get_config_obj, manager, 'myrepo', 'myrepo') manager = central.ConfigManager( @@ -196,7 +196,7 @@ class ConfigManagerTest(TestCase): }], debug=True) self.check_error( "Failed instantiating section 'myrepo':\n" - "Failed instantiating section 'myrepo': exception caught from 'pkgcore.test.config.test_central.myrepo':\n" + "Failed instantiating section 'myrepo': exception caught from 'tests.config.test_central.myrepo':\n" "I raised", self.get_config_obj, manager, 'myrepo', 'myrepo', klass=errors.ConfigurationError) @@ -228,7 +228,7 @@ class ConfigManagerTest(TestCase): 'class': autoloader, })}]) self.assertEqual(set(['autoload-sub', 'spork']), set(manager.sections())) - self.assertEqual(['spork'], manager.objects.repo.keys()) + self.assertEqual(['spork'], list(manager.objects.repo.keys())) self.assertEqual( 'test', manager.collapse_named_section('spork').instantiate()) @@ -245,7 +245,7 @@ class ConfigManagerTest(TestCase): 'class': autoloader})}]) self.assertEqual(set(['autoload-sub', 'spork']), set(manager.sections())) - self.assertEqual(['spork'], manager.objects.repo.keys()) + self.assertEqual(['spork'], list(manager.objects.repo.keys())) collapsedspork = manager.collapse_named_section('spork') self.assertEqual('test', collapsedspork.instantiate()) mod_dict['cache'] = 'modded' @@ -304,13 +304,13 @@ class ConfigManagerTest(TestCase): for i in range(3): self.check_error( "Failed instantiating section 'spork':\n" - "Failed instantiating section 'spork': exception caught from 'pkgcore.test.config.test_central.myrepo':\n" + "Failed instantiating section 'spork': exception caught from 'tests.config.test_central.myrepo':\n" "'I suck', callable unset!", spork.instantiate) for i in range(3): self.check_error( "Failed instantiating section 'spork':\n" - "Failed instantiating section 'spork': exception caught from 'pkgcore.test.config.test_central.myrepo':\n" + "Failed instantiating section 'spork': exception caught from 'tests.config.test_central.myrepo':\n" "'I suck', callable unset!", manager.collapse_named_section('spork').instantiate) @@ -322,7 +322,7 @@ class ConfigManagerTest(TestCase): manager = central.ConfigManager( [{'spork': basics.HardCodedConfigSection({'class': myrepo}), 'drawer': basics.ConfigSectionFromStringDict({ - 'class': 'pkgcore.test.config.test_central.drawer', + 'class': 'tests.config.test_central.drawer', 'content': 'spork', }), }]) @@ -336,7 +336,7 @@ class ConfigManagerTest(TestCase): def test_collapse_named_errors(self): manager = central.ConfigManager( [{'spork': basics.ConfigSectionFromStringDict({ - 'class': 'pkgcore.test.config.test_central.drawer', + 'class': 'tests.config.test_central.drawer', 'content': 'ref'})}], [RemoteSource()]) self.assertRaises(KeyError, self.get_config_obj, manager, 'repo', 'foon') self.check_error( @@ -364,13 +364,13 @@ class ConfigManagerTest(TestCase): def test_recursive_section_ref(self): manager = central.ConfigManager( [{'spork': basics.ConfigSectionFromStringDict({ - 'class': 'pkgcore.test.config.test_central.drawer', + 'class': 'tests.config.test_central.drawer', 'content': 'foon'}), 'foon': basics.ConfigSectionFromStringDict({ - 'class': 'pkgcore.test.config.test_central.drawer', + 'class': 'tests.config.test_central.drawer', 'content': 'spork'}), 'self': basics.ConfigSectionFromStringDict({ - 'class': 'pkgcore.test.config.test_central.drawer', + 'class': 'tests.config.test_central.drawer', 'content': 'self'}), }]) self.check_error( @@ -389,10 +389,10 @@ class ConfigManagerTest(TestCase): def test_recursive_inherit(self): manager = central.ConfigManager( [{'spork': basics.ConfigSectionFromStringDict({ - 'class': 'pkgcore.test.config.test_central.drawer', + 'class': 'tests.config.test_central.drawer', 'inherit': 'foon'}), 'foon': basics.ConfigSectionFromStringDict({ - 'class': 'pkgcore.test.config.test_central.drawer', + 'class': 'tests.config.test_central.drawer', 'inherit': 'spork'}), }]) self.check_error( @@ -518,14 +518,14 @@ class ConfigManagerTest(TestCase): "Failed instantiating section 'one':\n" "Instantiating reference 'content' pointing at None:\n" "Failed instantiating section None:\n" - "Failed instantiating section None: exception caught from 'pkgcore.test.config.test_central.broken':\n" + "Failed instantiating section None: exception caught from 'tests.config.test_central.broken':\n" "'broken', callable unset!", manager.collapse_named_section('one').instantiate) self.check_error( "Failed instantiating section 'multi':\n" "Instantiating reference 'contents' pointing at None:\n" "Failed instantiating section None:\n" - "Failed instantiating section None: exception caught from 'pkgcore.test.config.test_central.broken':\n" + "Failed instantiating section None: exception caught from 'tests.config.test_central.broken':\n" "'broken', callable unset!", manager.collapse_named_section('multi').instantiate) @@ -536,7 +536,7 @@ class ConfigManagerTest(TestCase): self.check_error( "Failed loading autoload section 'autoload_broken':\n" "Failed instantiating section 'autoload_broken':\n" - "Failed instantiating section 'autoload_broken': exception caught from 'pkgcore.test.config.test_central.broken':\n" + "Failed instantiating section 'autoload_broken': exception caught from 'tests.config.test_central.broken':\n" "'broken', callable unset!", central.ConfigManager, [{ 'autoload_broken': basics.HardCodedConfigSection({ @@ -641,7 +641,7 @@ class ConfigManagerTest(TestCase): section = basics.HardCodedConfigSection({'inherit': ['self']}) manager = central.ConfigManager([{ 'self': basics.ConfigSectionFromStringDict({ - 'class': 'pkgcore.test.config.test_central.drawer', + 'class': 'tests.config.test_central.drawer', 'inherit': 'self'}), }], [RemoteSource()]) self.check_error( diff --git a/tests/config/test_cparser.py b/tests/config/test_cparser.py index 39a92e82..e0a302c7 100644 --- a/tests/config/test_cparser.py +++ b/tests/config/test_cparser.py @@ -1,7 +1,7 @@ # Copyright: 2005 Marien Zwart <marienz@gentoo.org> # License: BSD/GPL2 -from StringIO import StringIO +from io import StringIO import sys from pkgcore.config import cparser, central, errors @@ -40,7 +40,7 @@ list.append = post bits true = yes false = no ''')) - self.assertEqual(config.keys(), ['test']) + self.assertEqual(list(config.keys()), ['test']) section = config['test'] for key, arg_type, value in [ ('string', 'str', [None, 'hi I am a string', None]), diff --git a/tests/config/test_dhcpformat.py b/tests/config/test_dhcpformat.py index d0d0be26..1b5cd817 100644 --- a/tests/config/test_dhcpformat.py +++ b/tests/config/test_dhcpformat.py @@ -1,7 +1,7 @@ # Copyright: 2005 Marien Zwart <marienz@gentoo.org> # License: BSD/GPL2 -from StringIO import StringIO +from io import StringIO try: import pyparsing @@ -43,10 +43,10 @@ test { '''), ]: config = parser(StringIO(text)) - self.assertEqual(config.keys(), ['test']) + self.assertEqual(list(config.keys()), ['test']) section = config['test'] self.assertTrue('hi' in section) - self.assertEqual(section.keys(), ['hi']) + self.assertEqual(list(section.keys()), ['hi']) self.assertEqual(section.render_value(None, 'hi', 'str'), [None, 'there', None]) @@ -57,7 +57,7 @@ test { list one two three; string hi; bool yes; - callable pkgcore.test.config.test_dhcpformat.passthrough; + callable tests.config.test_dhcpformat.passthrough; } '''), (mke2fsformat.config_from_file, ''' @@ -65,7 +65,7 @@ test { list = one two three string = hi bool = yes - callable = pkgcore.test.config.test_dhcpformat.passthrough + callable = tests.config.test_dhcpformat.passthrough '''), ]: config = parser(StringIO(text)) @@ -83,7 +83,7 @@ test { ('string', 'str', 'hi'), ('bool', 'str', 'yes'), ('callable', 'str', - 'pkgcore.test.config.test_dhcpformat.passthrough'), + 'tests.config.test_dhcpformat.passthrough'), ): self.assertEqual( (typename, value), section.render_value(None, name, 'repr')) @@ -92,27 +92,27 @@ test { for parser, text in [ (dhcpformat.config_from_file, ''' target { - class pkgcore.test.config.test_dhcpformat.testtype; + class tests.config.test_dhcpformat.testtype; hi there; } test { ref target; inline { - class pkgcore.test.config.test_dhcpformat.testtype; + class tests.config.test_dhcpformat.testtype; hi here; }; } '''), (mke2fsformat.config_from_file, ''' [target] - class = pkgcore.test.config.test_dhcpformat.testtype + class = tests.config.test_dhcpformat.testtype hi = there [test] ref = target inline = { - class = pkgcore.test.config.test_dhcpformat.testtype + class = tests.config.test_dhcpformat.testtype hi = here } '''), @@ -136,41 +136,41 @@ test { for parser, text in [ (dhcpformat.config_from_file, ''' target { - class pkgcore.test.config.test_dhcpformat.testtype; + class tests.config.test_dhcpformat.testtype; hi there; } test { ref target target; inline { - class pkgcore.test.config.test_dhcpformat.testtype; + class tests.config.test_dhcpformat.testtype; hi here; } { - class pkgcore.test.config.test_dhcpformat.testtype; + class tests.config.test_dhcpformat.testtype; hi here; }; mix target { - class pkgcore.test.config.test_dhcpformat.testtype; + class tests.config.test_dhcpformat.testtype; hi here; }; } '''), (mke2fsformat.config_from_file, ''' [target] - class = pkgcore.test.config.test_dhcpformat.testtype + class = tests.config.test_dhcpformat.testtype hi = there [test] ref = target target inline = { - class = pkgcore.test.config.test_dhcpformat.testtype + class = tests.config.test_dhcpformat.testtype hi = here } { - class = pkgcore.test.config.test_dhcpformat.testtype + class = tests.config.test_dhcpformat.testtype hi = here } mix = target { - class = pkgcore.test.config.test_dhcpformat.testtype + class = tests.config.test_dhcpformat.testtype hi = here } '''), @@ -196,25 +196,25 @@ test { for parser, text in [ (dhcpformat.config_from_file, ''' target { - class pkgcore.test.config.test_dhcpformat.testtype; + class tests.config.test_dhcpformat.testtype; hi there; } test { refs target { - class pkgcore.test.config.test_dhcpformat.testtype; + class tests.config.test_dhcpformat.testtype; hi here; }; } '''), (mke2fsformat.config_from_file, ''' [target] - class = pkgcore.test.config.test_dhcpformat.testtype + class = tests.config.test_dhcpformat.testtype hi = there [test] refs = target { - class = pkgcore.test.config.test_dhcpformat.testtype + class = tests.config.test_dhcpformat.testtype hi = here } '''), @@ -230,13 +230,13 @@ test { for parser, text in [ (dhcpformat.config_from_file, ''' target { - class pkgcore.test.config.test_dhcpformat.testtype; + class tests.config.test_dhcpformat.testtype; hi there; } test { inline { - class pkgcore.test.config.test_dhcpformat.testtype; + class tests.config.test_dhcpformat.testtype; hi here; }; ref target; @@ -244,12 +244,12 @@ test { '''), (mke2fsformat.config_from_file, ''' [target] - class = pkgcore.test.config.test_dhcpformat.testtype + class = tests.config.test_dhcpformat.testtype hi = there [test] inline = { - class = pkgcore.test.config.test_dhcpformat.testtype + class = tests.config.test_dhcpformat.testtype hi = here } ref = target diff --git a/tests/config/test_init.py b/tests/config/test_init.py index 1e18ba51..ddbfad0d 100644 --- a/tests/config/test_init.py +++ b/tests/config/test_init.py @@ -22,7 +22,7 @@ class ConfigLoadingTest(TestCase): self.user_config = mk_named_tempfile() self.user_config.write( '[foo]\n' - 'class = pkgcore.test.config.test_init.passthrough\n' + 'class = tests.config.test_init.passthrough\n' ) self.user_config.flush() self.system_config = mk_named_tempfile() diff --git a/tests/ebuild/__init__.py b/tests/ebuild/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/ebuild/__init__.py diff --git a/tests/ebuild/test_atom.py b/tests/ebuild/test_atom.py index 0a6a9f8b..7c7d8841 100644 --- a/tests/ebuild/test_atom.py +++ b/tests/ebuild/test_atom.py @@ -2,9 +2,9 @@ # License: GPL2/BSD from functools import partial +from pickle import dumps, loads from snakeoil.compatibility import cmp -from snakeoil.pickling import dumps, loads from snakeoil.test import mk_cpy_loadable_testcase from pkgcore import test @@ -17,7 +17,7 @@ from pkgcore.test.misc import FakePkg, FakeRepo class Test_native_atom(test.TestRestriction): class kls(atom.atom): - locals().update(atom.native_atom_overrides.iteritems()) + locals().update(atom.native_atom_overrides.items()) __inst_caching__ = True __slots__ = () @@ -60,7 +60,7 @@ class Test_native_atom(test.TestRestriction): "!!dev-util/diffball", eapi=1) self.assertRaises(errors.MalformedAtom, self.kls, "!!!dev-util/diffball", eapi=2) - for x in xrange(0,2): + for x in range(0, 2): obj = self.kls("!dev-util/diffball", eapi=x) self.assertTrue(obj.blocks) self.assertTrue(obj.blocks_temp_ignorable) @@ -393,7 +393,7 @@ class Test_native_atom(test.TestRestriction): self.assertRaises(errors.MalformedAtom, self.kls, "dev-util/foon::") self.assertRaises(errors.MalformedAtom, self.kls, "dev-util/foon::-gentoo-x86") self.assertRaises(errors.MalformedAtom, self.kls, "dev-util/foon:::") - for x in xrange(0, 3): + for x in range(0, 3): self.assertRaises(errors.MalformedAtom, self.kls, "dev-util/foon::gentoo-x86", eapi=x) diff --git a/tests/ebuild/test_conditionals.py b/tests/ebuild/test_conditionals.py index 690c4861..f372c33e 100644 --- a/tests/ebuild/test_conditionals.py +++ b/tests/ebuild/test_conditionals.py @@ -110,7 +110,7 @@ class native_DepSetParsingTest(base): s, v = s v2 = [] for x in v: - if isinstance(x, basestring): + if isinstance(x, str): v2.append(x) else: v2.append(x[-1] + '?') @@ -235,10 +235,10 @@ class native_DepSetConditionalsInspectionTest(base): def check_conds(self, s, r, msg=None, element_kls=str, **kwds): nc = {k: self.flatten_cond(v) for k, v in - self.gen_depset(s, element_kls=element_kls, **kwds).node_conds.iteritems()} - d = {element_kls(k): v for k, v in r.iteritems()} - for k, v in d.iteritems(): - if isinstance(v, basestring): + self.gen_depset(s, element_kls=element_kls, **kwds).node_conds.items()} + d = {element_kls(k): v for k, v in r.items()} + for k, v in d.items(): + if isinstance(v, str): d[k] = set([frozenset(v.split())]) elif isinstance(v, (tuple, list)): d[k] = set(map(frozenset, v)) @@ -279,7 +279,7 @@ class cpy_DepSetConditionalsInspectionTest( class native_DepSetEvaluateTest(base): def test_evaluation(self): - flag_set = list(sorted("x%i" % (x,) for x in xrange(2000))) + flag_set = list(sorted("x%i" % (x,) for x in range(2000))) for vals in ( ("y", "x? ( y ) !x? ( z )", "x"), ("z", "x? ( y ) !x? ( z )"), diff --git a/tests/ebuild/test_cpv.py b/tests/ebuild/test_cpv.py index 5f3cf233..c498ea3d 100644 --- a/tests/ebuild/test_cpv.py +++ b/tests/ebuild/test_cpv.py @@ -11,7 +11,7 @@ from pkgcore.ebuild import cpv def generate_misc_sufs(): simple_good_sufs = ["_alpha", "_beta", "_pre", "_p"] - suf_nums = list(xrange(100)) + suf_nums = list(range(100)) shuffle(suf_nums) good_sufs = (simple_good_sufs +["%s%i" % (x, suf_nums.pop()) @@ -19,7 +19,7 @@ def generate_misc_sufs(): l = len(good_sufs) good_sufs = good_sufs + [ - good_sufs[x] + good_sufs[l - x - 1] for x in xrange(l)] + good_sufs[x] + good_sufs[l - x - 1] for x in range(l)] bad_sufs = ["_a", "_9", "_"] + [x+" " for x in simple_good_sufs] return good_sufs, bad_sufs @@ -79,7 +79,7 @@ class native_CpvTest(TestCase): key = src[0] else: key = src[1] - if isinstance(src[0], basestring): + if isinstance(src[0], str): cat, pkgver = src[0].rsplit("/", 1) vals = pkgver.rsplit("-", 1) if len(vals) == 1: @@ -124,8 +124,8 @@ class native_CpvTest(TestCase): for x in (10, 18, 19, 36, 100): self.assertEqual(self.kls("da", "ba", "1-r0%s" % ("0" * x)).revision, None) - self.assertEqual(long(self.kls("da", "ba", "1-r1%s1" % ("0" * x)).revision), - long("1%s1" % ("0" * x))) + self.assertEqual(int(self.kls("da", "ba", "1-r1%s1" % ("0" * x)).revision), + int("1%s1" % ("0" * x))) def process_pkg(self, ret, cat, pkg): diff --git a/tests/ebuild/test_digest.py b/tests/ebuild/test_digest.py index f8859155..80e780fd 100644 --- a/tests/ebuild/test_digest.py +++ b/tests/ebuild/test_digest.py @@ -21,10 +21,10 @@ MD5 2fa54dd51b6a8f1c46e5baf741e90f7e python-2.4-patches-1.tar.bz2 7820 RMD160 313c0f4f4dea59290c42a9b2c8de1db159f1ca1b python-2.4-patches-1.tar.bz2 7820 SHA256 e22abe4394f1f0919aac429f155c00ec1b3fe94cdc302119059994d817cd30b5 python-2.4-patches-1.tar.bz2 7820""" digest_chksum = ( - ("size", long(7853169)), - ("md5", long("98db1465629693fc434d4dc52db93838", 16)), - ("rmd160", long("c511d2b76b5394742d285e71570a2bcd3c1fa871", 16)), - ("sha256", long("e163b95ee56819c0f3c58ef9278c30b9e49302c2f1a1917680ca894d33929f7e", 16)) + ("size", int(7853169)), + ("md5", int("98db1465629693fc434d4dc52db93838", 16)), + ("rmd160", int("c511d2b76b5394742d285e71570a2bcd3c1fa871", 16)), + ("sha256", int("e163b95ee56819c0f3c58ef9278c30b9e49302c2f1a1917680ca894d33929f7e", 16)) ) # ripped straight from the glep @@ -46,8 +46,8 @@ for x in pure_manifest2.split("\n"): if not l: continue i = iter(l[3:]) - chksum = [("size", long(l[2]))] - chksum += [(k.lower(), long(v, 16)) for k, v in zip(i, i)] + chksum = [("size", int(l[2]))] + chksum += [(k.lower(), int(v, 16)) for k, v in zip(i, i)] chksum = tuple(chksum) pure_manifest2_chksums.setdefault(l[0], {})[l[1]] = chksum del chksum, l, i @@ -83,9 +83,9 @@ class TestManifest(TestCase): ("EBUILD", ebuild), ("MISC", misc)): req_d = pure_manifest2_chksums[dtype] self.assertEqual(sorted(req_d), sorted(d)) - for k, v in req_d.iteritems(): + for k, v in req_d.items(): i1 = sorted(v) - i2 = sorted(d[k].iteritems()) + i2 = sorted(d[k].items()) self.assertEqual(i1, i2, msg="%r != %r\nfor %s %s" % (i1, i2, dtype, k)) diff --git a/tests/ebuild/test_ebuild_src.py b/tests/ebuild/test_ebuild_src.py index 11137bd4..7099acc7 100644 --- a/tests/ebuild/test_ebuild_src.py +++ b/tests/ebuild/test_ebuild_src.py @@ -14,7 +14,7 @@ from pkgcore.ebuild import ebuild_src, digest, repo_objs from pkgcore.ebuild.eapi import get_eapi from pkgcore.package import errors from pkgcore.test import malleable_obj -from pkgcore.test.ebuild.test_eclass_cache import FakeEclassCache +from tests.ebuild.test_eclass_cache import FakeEclassCache class test_base(TestCase): @@ -138,7 +138,7 @@ class test_base(TestCase): def test_restrict(self): o = self.get_pkg({'RESTRICT': 'strip fetch strip'}) - self.assertEqual(*map(sorted, (o.restrict, ['strip', 'fetch', 'strip']))) + self.assertEqual(*list(map(sorted, (o.restrict, ['strip', 'fetch', 'strip'])))) # regression test to ensure it onnly grabs 'no' prefix, instead of lstriping it self.assertEqual(list(self.get_pkg({'RESTRICT': 'onoasdf'}).restrict), ['onoasdf']) @@ -212,7 +212,7 @@ class test_base(TestCase): self.assertEqual(l, [o]) # basic tests; - for x in xrange(0,3): + for x in range(0, 3): f = self.get_pkg({'SRC_URI':'http://foo.com/monkey.tgz', 'EAPI':str(x)}, repo=parent).fetchables @@ -321,11 +321,11 @@ class test_package(test_base): l = [] def f(self, cpv): l.append(cpv) - return 100l + return 100 parent = self.make_parent(_get_ebuild_mtime=f) o = self.get_pkg(repo=parent) - self.assertEqual(o._mtime_, 100l) + self.assertEqual(o._mtime_, 100) self.assertEqual(l, [o]) def make_shared_pkg_data(self, manifest=None, metadata_xml=None): @@ -356,13 +356,13 @@ class test_package_factory(TestCase): def mkinst(self, repo=None, cache=(), eclasses=None, mirrors={}, default_mirrors={}, **overrides): o = self.kls(repo, cache, eclasses, mirrors, default_mirrors) - for k, v in overrides.iteritems(): + for k, v in overrides.items(): object.__setattr__(o, k, v) return o def test_mirrors(self): mirrors_d = {'gentoo':['http://bar/', 'http://far/']} - mirrors = {k: fetch.mirror(v, k) for k, v in mirrors_d.iteritems()} + mirrors = {k: fetch.mirror(v, k) for k, v in mirrors_d.items()} pf = self.mkinst(mirrors=mirrors_d) self.assertLen(pf._cache, 0) self.assertEqual(sorted(pf.mirrors), sorted(mirrors)) @@ -422,7 +422,7 @@ class test_package_factory(TestCase): {'marker':1, '_mtime_':100}, reflective=False) - self.assertEqual(cache1.keys(), [pkg.cpvstr]) + self.assertEqual(list(cache1.keys()), [pkg.cpvstr]) self.assertFalse(cache2) # mtime was wiped, thus no longer is usable. @@ -439,7 +439,7 @@ class test_package_factory(TestCase): }) cache2.readonly = True self.assertRaises(explode_kls, pf._get_metadata, pkg) - self.assertEqual(cache2.keys(), [pkg.cpvstr]) + self.assertEqual(list(cache2.keys()), [pkg.cpvstr]) # keep in mind the backend assumes it gets its own copy of the data. # thus, modifying (popping _mtime_) _is_ valid self.assertEqual(cache2[pkg.cpvstr], diff --git a/tests/ebuild/test_eclass_cache.py b/tests/ebuild/test_eclass_cache.py index 0468fa52..4da78fa2 100644 --- a/tests/ebuild/test_eclass_cache.py +++ b/tests/ebuild/test_eclass_cache.py @@ -41,7 +41,7 @@ class TestBase(TestCase): assertRebuildResults(False, 'eclass1', 200) def test_get_eclass_data(self): - keys = self.ec.eclasses.keys() + keys = list(self.ec.eclasses.keys()) data = self.ec.get_eclass_data([]) self.assertIdentical(data, self.ec.get_eclass_data([])) data = self.ec.get_eclass_data(keys) diff --git a/tests/ebuild/test_formatter.py b/tests/ebuild/test_formatter.py index bc2eb780..d54fb605 100644 --- a/tests/ebuild/test_formatter.py +++ b/tests/ebuild/test_formatter.py @@ -95,7 +95,7 @@ class BaseFormatterTest(object): args.append(suffix) for arg in args: - if isinstance(arg, unicode): + if isinstance(arg, str): stringlist.append(arg.encode('ascii')) elif isinstance(arg, bytes): stringlist.append(arg) diff --git a/tests/ebuild/test_misc.py b/tests/ebuild/test_misc.py index 08ca7f74..370da729 100644 --- a/tests/ebuild/test_misc.py +++ b/tests/ebuild/test_misc.py @@ -19,7 +19,7 @@ class base(TestCase): reflective=False) atoms_dict = {a[0].key: (a, a[1]) for a in atoms} self.assertEqual(sorted(obj.atoms), sorted(atoms_dict)) - for k, v in obj.atoms.iteritems(): + for k, v in obj.atoms.items(): l1 = sorted((x[0], list(x[1])) for x in v) l2 = sorted((x[0], list(x[1])) for x, y in atoms_dict[k]) @@ -32,7 +32,7 @@ class test_collapsed_restrict_to_data(base): kls = misc.collapsed_restrict_to_data def test_defaults(self): - srange = map(str, xrange(100)) + srange = list(map(str, range(100))) self.assertState(self.kls([(AlwaysTrue, srange)]), defaults=srange) # ensure AlwaysFalse is ignored. @@ -85,7 +85,7 @@ class TestIncrementalsDict(TestCase): kls = misc.IncrementalsDict def assertContents(self, mapping1, mapping2): - self.assertEqual(sorted(mapping1.iteritems()), sorted(mapping2.iteritems())) + self.assertEqual(sorted(mapping1.items()), sorted(mapping2.items())) def test_behaviour(self): d = self.kls(frozenset("i1 i2".split()), a1="1", i1="1") diff --git a/tests/ebuild/test_portage_conf.py b/tests/ebuild/test_portage_conf.py index 8b552849..a3896e17 100644 --- a/tests/ebuild/test_portage_conf.py +++ b/tests/ebuild/test_portage_conf.py @@ -172,7 +172,7 @@ class TestPortageConfig(TempDirMixin, TestCase): f.flush() defaults, repos = load_repos_conf(f.name) self.assertEqual('gentoo', defaults['main-repo']) - self.assertEqual(['foo', 'gentoo'], repos.keys()) + self.assertEqual(['foo', 'gentoo'], list(repos.keys())) # TODO: check for logger output? # overriding defaults in the same file throws an exception from configparser @@ -218,4 +218,4 @@ class TestPortageConfig(TempDirMixin, TestCase): self.assertEqual(defaults, sym_defaults) self.assertEqual(repos, sym_repos) self.assertEqual('gentoo', defaults['main-repo']) - self.assertEqual(['foo', 'bar', 'gentoo'], repos.keys()) + self.assertEqual(['foo', 'bar', 'gentoo'], list(repos.keys())) diff --git a/tests/ebuild/test_profiles.py b/tests/ebuild/test_profiles.py index 07dda7bf..99947a53 100644 --- a/tests/ebuild/test_profiles.py +++ b/tests/ebuild/test_profiles.py @@ -45,7 +45,7 @@ class profile_mixin(TempDirMixin): path = pjoin(self.dir, name) ensure_dirs(path) parent = vals.pop("parent", None) - for fname, data in vals.iteritems(): + for fname, data in vals.items(): with open(pjoin(path, fname), "w") as f: f.write(data) @@ -56,7 +56,7 @@ class profile_mixin(TempDirMixin): with open(pjoin(path, "parent"), "w") as f: f.write("../%s" % (parent,)) if kwds: - for key, val in kwds.iteritems(): + for key, val in kwds.items(): with open(pjoin(self.dir, key), "w") as f: f.write(val) @@ -79,7 +79,7 @@ class profile_mixin(TempDirMixin): self.assertEqual(keys1, keys2, msg="keys differ: wanted %r got %r\nfrom %r" % (keys2, keys1, given_mapping)) - for key, desired in desired_mapping.iteritems(): + for key, desired in desired_mapping.items(): got = given_mapping[key] # sanity check the desired data, occasionally screw this up self.assertNotInstance(desired, bare_kls, msg="key %r, bad test invocation; " @@ -90,7 +90,7 @@ class profile_mixin(TempDirMixin): "rather than tuple: %r" % (key, bare_kls.__name__, got)) if not all(isinstance(x, bare_kls) for x in got): self.fail("non %s instance: key %r, val %r; types %r" % (bare_kls.__name__, - key, got, map(type, got))) + key, got, list(map(type, got)))) got2, desired2 = tuple(map(reformat_f, got)), tuple(map(reformat_f, desired)) self.assertEqual(got2, desired2, msg="key %r isn't equal; wanted %r, got %r" % (key, desired2, got2)) diff --git a/tests/ebuild/test_repo_objs.py b/tests/ebuild/test_repo_objs.py index fffc1c79..64f34c49 100644 --- a/tests/ebuild/test_repo_objs.py +++ b/tests/ebuild/test_repo_objs.py @@ -24,7 +24,7 @@ class TestMetadataXml(TestCase): "</maintainer><maintainer>".join(ms) if local_use: us = ['<use>'] - for flag, desc in local_use.iteritems(): + for flag, desc in local_use.items(): us.append('<flag name="%s">%s</flag>' % (flag, desc)) us.append('</use>') us = '\n'.join(us) @@ -49,11 +49,11 @@ class TestMetadataXml(TestCase): # test email/name integration. mx = self.get_metadata_xml( maintainers=(("funkymonkey@gmail.com", - u"funky monkey \N{SNOWMAN}"),)) - self.assertEqual((u"funky monkey \N{SNOWMAN} <funkymonkey@gmail.com>",), - tuple(unicode(m) for m in mx.maintainers)) + "funky monkey \N{SNOWMAN}"),)) + self.assertEqual(("funky monkey \N{SNOWMAN} <funkymonkey@gmail.com>",), + tuple(str(m) for m in mx.maintainers)) self.assertEqual("funkymonkey@gmail.com", mx.maintainers[0].email) - self.assertEqual(u"funky monkey \N{SNOWMAN}", mx.maintainers[0].name) + self.assertEqual("funky monkey \N{SNOWMAN}", mx.maintainers[0].name) def test_local_use(self): # empty... @@ -67,7 +67,7 @@ class TestMetadataXml(TestCase): pkg_tag_re = re.compile(r'</?pkg>') local_use = dict( (k, pkg_tag_re.sub('', v)) - for k, v in local_use.iteritems()) + for k, v in local_use.items()) self.assertEqual(local_use, metadata_xml.local_use) def test_longdesc(self): diff --git a/tests/ebuild/test_repository.py b/tests/ebuild/test_repository.py index f0415086..445b5b10 100644 --- a/tests/ebuild/test_repository.py +++ b/tests/ebuild/test_repository.py @@ -64,11 +64,11 @@ class UnconfiguredTreeTest(TempDirMixin): sorted(mirrors['spork'])) with open(pjoin(self.pdir, 'thirdpartymirrors'), 'w') as f: f.write("foon dar\n") - self.assertEqual(self.mk_tree(self.dir).mirrors.keys(), ['foon']) + self.assertEqual(list(self.mk_tree(self.dir).mirrors.keys()), ['foon']) def test_repo_id(self): dir1 = pjoin(self.dir, '1') - os.mkdir(dir1, 0755) + os.mkdir(dir1, 0o755) repo = self.mk_tree(dir1) self.assertEqual(repo.repo_id, '<unlabeled repo %s>' % (dir1,)) dir2 = pjoin(self.dir, '2') @@ -259,9 +259,9 @@ class SlavedTreeTest(UnconfiguredTreeTest): with open(pjoin(self.slave_pdir, 'categories'), 'w') as f: f.write('\n'.join(slave)) for cat in master: - os.mkdir(pjoin(self.dir_master, cat), 0755) + os.mkdir(pjoin(self.dir_master, cat), 0o755) for cat in slave: - os.mkdir(pjoin(self.dir_slave, cat), 0755) + os.mkdir(pjoin(self.dir_slave, cat), 0o755) return self.mk_tree(self.dir) def test_categories(self): diff --git a/tests/fetch/__init__.py b/tests/fetch/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/fetch/__init__.py diff --git a/tests/fetch/test_base.py b/tests/fetch/test_base.py index 23710dea..69afc1d3 100644 --- a/tests/fetch/test_base.py +++ b/tests/fetch/test_base.py @@ -19,10 +19,10 @@ handlers = get_handlers() from snakeoil.mappings import LazyValDict def _callback(chf): return handlers[chf](data_source.data_source(data)) -chksums = LazyValDict(frozenset(handlers.iterkeys()), _callback) +chksums = LazyValDict(frozenset(handlers.keys()), _callback) # get a non size based chksum -known_chksum = [x for x in handlers.iterkeys() if x != "size"][0] +known_chksum = [x for x in handlers.keys() if x != "size"][0] class TestFetcher(TempDirMixin, TestCase): @@ -68,7 +68,7 @@ class TestFetcher(TempDirMixin, TestCase): def test_verify_all_chksums(self): self.write_data() - subhandlers = dict([handlers.items()[0]]) + subhandlers = dict([list(handlers.items())[0]]) self.assertRaises(errors.RequiredChksumDataMissing, self.fetcher._verify, self.fp, self.obj, handlers=subhandlers) self.fetcher._verify(self.fp, self.obj) @@ -77,7 +77,7 @@ class TestFetcher(TempDirMixin, TestCase): def test_size_verification_first(self): self.write_data() - chksum_data = dict(chksums.iteritems()) + chksum_data = dict(chksums.items()) l = [] def f(chf, fp): l.append(chf) diff --git a/tests/fs/__init__.py b/tests/fs/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/fs/__init__.py diff --git a/tests/fs/test_contents.py b/tests/fs/test_contents.py index 5e20ccf5..690badba 100644 --- a/tests/fs/test_contents.py +++ b/tests/fs/test_contents.py @@ -29,17 +29,17 @@ class TestContentsSet(TestCase): def __init__(self, *a, **kw): TestCase.__init__(self, *a, **kw) - self.files = map(self.mk_file, ["/etc/blah", "/etc/foo", "/etc/dar", + self.files = list(map(self.mk_file, ["/etc/blah", "/etc/foo", "/etc/dar", "/tmp/dar", - "/tmp/blah/foo/long/ass/file/name/but/not/that/bad/really"]) - self.dirs = map(self.mk_dir, ["/tmp", "/blah", "/tmp/dar", - "/usr/", "/usr/bin"]) + "/tmp/blah/foo/long/ass/file/name/but/not/that/bad/really"])) + self.dirs = list(map(self.mk_dir, ["/tmp", "/blah", "/tmp/dar", + "/usr/", "/usr/bin"])) self.links = [fs.fsLink(x, os.path.dirname(x), strict=False) for x in ["/tmp/foo", "/usr/X11R6/lib", "/nagga/noo"]] - self.devs = map(self.mk_dev, - [pjoin("dev", x) for x in ["sda1", "hda", "hda2", "disks/ide1"]]) - self.fifos = map(self.mk_fifo, - [pjoin("tmp", y) for y in ("dar", "boo", "bah")]) + self.devs = list(map(self.mk_dev, + [pjoin("dev", x) for x in ["sda1", "hda", "hda2", "disks/ide1"]])) + self.fifos = list(map(self.mk_fifo, + [pjoin("tmp", y) for y in ("dar", "boo", "bah")])) self.all = self.dirs + self.links + self.devs + self.fifos def test_init(self): @@ -53,8 +53,8 @@ class TestContentsSet(TestCase): def test_add(self): cs = contents.contentsSet(self.files + self.dirs, mutable=True) - map(cs.add, self.links) for x in self.links: + cs.add(x) self.assertIn(x, cs) self.assertEqual( len(cs), @@ -70,9 +70,11 @@ class TestContentsSet(TestCase): self.assertRaises(AttributeError, contents.contentsSet(mutable=False).remove, 1) cs = contents.contentsSet(self.all, mutable=True) - map(cs.remove, self.all) + for x in self.all: + cs.remove(x) cs = contents.contentsSet(self.all, mutable=True) - map(cs.remove, (x.location for x in self.all)) + for location in (x.location for x in self.all): + cs.remove(location) self.assertEqual(len(cs), 0) self.assertRaises(KeyError, cs.remove, self.all[0]) @@ -104,7 +106,8 @@ class TestContentsSet(TestCase): s2 = set(getattr(cs, forced_name)()) if obj_class is not None: - map(post_curry(self.assertTrue, obj_class), s2) + for x in s2: + post_curry(self.assertTrue, obj_class)(x) self.assertEqual(s, s2) if forced_name == "__iter__": @@ -113,7 +116,8 @@ class TestContentsSet(TestCase): # inversion tests now. s3 = set(getattr(cs, forced_name)(invert=True)) if obj_class is not None: - map(post_curry(self.assertFalse, obj_class), s3) + for x in s3: + post_curry(self.assertFalse, obj_class)(x) self.assertEqual(s.symmetric_difference(s2), s3) @@ -190,7 +194,7 @@ class TestContentsSet(TestCase): check_set_op, "symmetric_difference_update", []) fstrings = ("/a", "/b", "/c", "/d") - f = map(mk_file, fstrings) + f = list(map(mk_file, fstrings)) test_union1 = post_curry(check_set_op, "union", ["/tmp"]) test_union2 = post_curry(check_set_op, "union", fstrings, [f[:2], f[2:]]) @@ -282,13 +286,13 @@ class TestContentsSet(TestCase): ['/dir1', '/dir1/a', '/dir1/dir4', '/dir2', '/dir2/dir3', '/dir2/dir3/b']) obj = cs['/dir1'] - self.assertEqual(obj.mode, 0775) + self.assertEqual(obj.mode, 0o775) def test_inode_map(self): def check_it(target): - d = {k: sorted(v) for k, v in cs.inode_map().iteritems()} - target = {k: sorted(v) for k, v in target.iteritems()} + d = {k: sorted(v) for k, v in cs.inode_map().items()} + target = {k: sorted(v) for k, v in target.items()} self.assertEqual(d, target) cs = contents.contentsSet() @@ -315,8 +319,8 @@ class Test_offset_rewriting(TestCase): offset_insert = staticmethod(contents.offset_rewriter) def test_offset_rewriter(self): - f = ["/foon/%i" % x for x in xrange(10)] - f.extend("/foon/%i/blah" % x for x in xrange(5)) + f = ["/foon/%i" % x for x in range(10)] + f.extend("/foon/%i/blah" % x for x in range(5)) f = [fs.fsFile(x, strict=False) for x in f] self.assertEqual(sorted(x.location for x in f), sorted(x.location for x in self.offset_insert('/', f))) @@ -325,8 +329,8 @@ class Test_offset_rewriting(TestCase): sorted(x.location for x in self.offset_insert('/usr', f))) def test_it(self): - f = ["/foon/%i" % x for x in xrange(10)] - f.extend("/foon/%i/blah" % x for x in xrange(5)) + f = ["/foon/%i" % x for x in range(10)] + f.extend("/foon/%i/blah" % x for x in range(5)) f = [fs.fsFile(x, strict=False) for x in f] self.assertEqual(sorted(x.location for x in f), sorted(y.location for y in self.change_offset('/usr', '/', diff --git a/tests/fs/test_fs.py b/tests/fs/test_fs.py index 47c6df64..0c8acfa9 100644 --- a/tests/fs/test_fs.py +++ b/tests/fs/test_fs.py @@ -42,10 +42,10 @@ class base(object): mkobj = self.make_obj o = mkobj("/tmp/foo") self.assertEqual(o.location, "/tmp/foo") - self.assertEqual(mkobj(mtime=100l).mtime, 100l) - self.assertEqual(mkobj(mode=0660).mode, 0660) + self.assertEqual(mkobj(mtime=100).mtime, 100) + self.assertEqual(mkobj(mode=0o660).mode, 0o660) # ensure the highband stays in.. - self.assertEqual(mkobj(mode=042660).mode, 042660) + self.assertEqual(mkobj(mode=0o42660).mode, 0o42660) self.assertEqual(mkobj(uid=0).uid, 0) self.assertEqual(mkobj(gid=0).gid, 0) @@ -115,13 +115,13 @@ class Test_fsFile(TestCase, base): o = mkobj("/bin/this-file-should-not-exist-nor-be-read", data=data_source(raw_data)) self.assertEqual(o.data.text_fileobj().read(), raw_data) - keys = o.chksums.keys() + keys = list(o.chksums.keys()) self.assertEqual([o.chksums[x] for x in keys], list(get_chksums(data_source(raw_data), *keys))) - chksums = dict(o.chksums.iteritems()) - self.assertEqual(sorted(mkobj(chksums=chksums).chksums.iteritems()), - sorted(chksums.iteritems())) + chksums = dict(iter(o.chksums.items())) + self.assertEqual(sorted(mkobj(chksums=chksums).chksums.items()), + sorted(chksums.items())) def test_chksum_regen(self): data_source = object() diff --git a/tests/fs/test_livefs.py b/tests/fs/test_livefs.py index 1e9308b5..5eee302c 100644 --- a/tests/fs/test_livefs.py +++ b/tests/fs/test_livefs.py @@ -21,7 +21,7 @@ class FsObjsTest(TempDirMixin, TestCase): if offset is not None: self.assertTrue(path.startswith("/"), msg="path must be absolute, got %r" % path) - self.assertEqual(obj.mode & 07777, st.st_mode & 07777) + self.assertEqual(obj.mode & 0o7777, st.st_mode & 0o7777) self.assertEqual(obj.uid, st.st_uid) self.assertEqual(obj.gid, st.st_gid) if fs.isreg(obj): @@ -77,10 +77,12 @@ class FsObjsTest(TempDirMixin, TestCase): files = [os.path.normpath(os.path.join(path, x)) for x in [ "tmp", "blah", "dar"]] # cheap version of a touch. - map(lambda x:open(x, "w").close(), files) + for x in files: + open(x, "w").close() dirs = [os.path.normpath(os.path.join(path, x)) for x in [ "a", "b", "c"]] - map(os.mkdir, dirs) + for x in dirs: + os.mkdir(x) dirs.append(path) for obj in livefs.iter_scan(path): self.assertInstance(obj, fs.fsBase) @@ -109,15 +111,17 @@ class FsObjsTest(TempDirMixin, TestCase): files = [os.path.normpath(os.path.join(path, x)) for x in ["tmp", "blah", "dar", ".foo", ".bar"]] # cheap version of a touch. - map(lambda x: open(x, "w").close(), files) + for x in files: + open(x, "w").close() dirs = [os.path.normpath(os.path.join(path, x)) for x in [ "a", "b", "c"]] - map(os.mkdir, dirs) + for x in dirs: + os.mkdir(x) # regular directory scanning sorted_files = livefs.sorted_scan(path) self.assertEqual( - list(map(lambda x: pjoin(path, x), ['blah', 'dar', 'tmp'])), + list([pjoin(path, x) for x in ['blah', 'dar', 'tmp']]), sorted_files) # nonexistent paths diff --git a/tests/fs/test_ops.py b/tests/fs/test_ops.py index f77c8cdb..58b217a4 100644 --- a/tests/fs/test_ops.py +++ b/tests/fs/test_ops.py @@ -22,19 +22,19 @@ class VerifyMixin(object): self.assertEqual(getattr(stat, attr), kwds[keyword], "testing %s" % (keyword,)) if "mode" in kwds: - self.assertEqual((stat.st_mode & 04777), kwds["mode"]) + self.assertEqual((stat.st_mode & 0o4777), kwds["mode"]) class TestDefaultEnsurePerms(VerifyMixin, TempDirMixin, TestCase): def common_bits(self, creator_func, kls): - kwds = {"mtime":01234, "uid":os.getuid(), "gid":os.getgid(), - "mode":0775, "dev":None, "inode":None} + kwds = {"mtime":0o1234, "uid":os.getuid(), "gid":os.getgid(), + "mode":0o775, "dev":None, "inode":None} o = kls(pjoin(self.dir, "blah"), **kwds) creator_func(o.location) self.assertTrue(ops.default_ensure_perms(o)) self.verify(o, kwds, os.stat(o.location)) - kwds["mode"] = 0770 + kwds["mode"] = 0o770 o2 = kls(pjoin(self.dir, "blah"), **kwds) self.assertTrue(ops.default_ensure_perms(o2)) self.verify(o2, kwds, os.stat(o.location)) @@ -56,13 +56,13 @@ class TestDefaultMkdir(TempDirMixin, TestCase): self.assertTrue(ops.default_mkdir(o)) old_umask = os.umask(0) try: - self.assertEqual((os.stat(o.location).st_mode & 04777), 0777 & ~old_umask) + self.assertEqual((os.stat(o.location).st_mode & 0o4777), 0o777 & ~old_umask) finally: os.umask(old_umask) os.rmdir(o.location) - o = fs.fsDir(pjoin(self.dir, "mkdir_test2"), strict=False, mode=0750) + o = fs.fsDir(pjoin(self.dir, "mkdir_test2"), strict=False, mode=0o750) self.assertTrue(ops.default_mkdir(o)) - self.assertEqual(os.stat(o.location).st_mode & 04777, 0750) + self.assertEqual(os.stat(o.location).st_mode & 0o4777, 0o750) class TestCopyFile(VerifyMixin, TempDirMixin, TestCase): @@ -71,9 +71,9 @@ class TestCopyFile(VerifyMixin, TempDirMixin, TestCase): src = pjoin(self.dir, "copy_test_src") dest = pjoin(self.dir, "copy_test_dest") with open(src, "w") as f: - f.writelines("asdf\n" for i in xrange(10)) + f.writelines("asdf\n" for i in range(10)) kwds = {"mtime":10321, "uid":os.getuid(), "gid":os.getgid(), - "mode":0664, "data":local_source(src), "dev":None, + "mode":0o664, "data":local_source(src), "dev":None, "inode":None} o = fs.fsFile(dest, **kwds) self.assertTrue(ops.default_copyfile(o)) @@ -90,7 +90,7 @@ class TestCopyFile(VerifyMixin, TempDirMixin, TestCase): group = group[0] fp = pjoin(self.dir, "sym") o = fs.fsSymlink(fp, mtime=10321, uid=os.getuid(), gid=group, - mode=0664, target='target') + mode=0o664, target='target') self.assertTrue(ops.default_copyfile(o)) self.assertEqual(os.lstat(fp).st_gid, group) self.assertEqual(os.lstat(fp).st_uid, os.getuid()) @@ -108,7 +108,7 @@ class TestCopyFile(VerifyMixin, TempDirMixin, TestCase): livefs.gen_obj(fp).change_attributes(location=path)) # test sym over a directory. - f = fs.fsSymlink(path, fp, mode=0644, mtime=0, uid=os.getuid(), + f = fs.fsSymlink(path, fp, mode=0o644, mtime=0, uid=os.getuid(), gid=os.getgid()) self.assertRaises(TypeError, ops.default_copyfile, f) os.unlink(fp) @@ -205,7 +205,7 @@ class Test_merge_contents(ContentsMixin): fp = pjoin(self.dir, "trg") os.mkdir(path) # test sym over a directory. - f = fs.fsSymlink(path, fp, mode=0644, mtime=0, uid=os.getuid(), + f = fs.fsSymlink(path, fp, mode=0o644, mtime=0, uid=os.getuid(), gid=os.getgid()) cset = contents.contentsSet([f]) self.assertRaises(ops.FailedCopy, ops.merge_contents, cset) @@ -218,7 +218,7 @@ class Test_merge_contents(ContentsMixin): # aren't dirs or symlinks to dirs path = pjoin(self.dir, "file2dir") open(path, 'w').close() - d = fs.fsDir(path, mode=0755, mtime=0, uid=os.getuid(), gid=os.getgid()) + d = fs.fsDir(path, mode=0o755, mtime=0, uid=os.getuid(), gid=os.getgid()) cset = contents.contentsSet([d]) self.assertRaises(ops.CannotOverwrite, ops.merge_contents, cset) @@ -255,7 +255,7 @@ class Test_unmerge_contents(ContentsMixin): def test_lingering_file(self): img, cset = self.generic_unmerge_bits(self.entries_norm1) - dirs = [k for k, v in self.entries_norm1.iteritems() if v[0] == "dir"] + dirs = [k for k, v in self.entries_norm1.items() if v[0] == "dir"] fp = os.path.join(img, dirs[0], "linger") open(fp, "w").close() self.assertTrue(ops.unmerge_contents(cset, offset=img)) diff --git a/tests/merge/__init__.py b/tests/merge/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/merge/__init__.py diff --git a/tests/merge/test_engine.py b/tests/merge/test_engine.py index b2874c83..a6837e2d 100644 --- a/tests/merge/test_engine.py +++ b/tests/merge/test_engine.py @@ -10,8 +10,8 @@ from snakeoil.test.mixins import tempdir_decorator from pkgcore.fs import livefs from pkgcore.fs.contents import contentsSet from pkgcore.merge import engine -from pkgcore.test.fs.fs_util import fsFile, fsDir, fsSymlink -from pkgcore.test.merge.util import fake_engine +from tests.fs.fs_util import fsFile, fsDir, fsSymlink +from tests.merge.util import fake_engine class fake_pkg(object): diff --git a/tests/merge/test_triggers.py b/tests/merge/test_triggers.py index 30c4a2a9..ffae7eb5 100644 --- a/tests/merge/test_triggers.py +++ b/tests/merge/test_triggers.py @@ -2,7 +2,7 @@ # License: GPL2/BSD from functools import partial -from itertools import izip + from math import floor, ceil import os import shutil @@ -17,7 +17,7 @@ from pkgcore.fs import fs from pkgcore.merge import triggers, const from pkgcore.fs.contents import contentsSet from pkgcore.fs.livefs import gen_obj, scan -from pkgcore.test.merge.util import fake_trigger, fake_engine, fake_reporter +from tests.merge.util import fake_trigger, fake_engine, fake_reporter def _render_msg(func, msg, *args, **kwargs): @@ -25,7 +25,7 @@ def _render_msg(func, msg, *args, **kwargs): def make_fake_reporter(**kwargs): kwargs = dict((key, partial(_render_msg, val)) - for key, val in kwargs.iteritems()) + for key, val in kwargs.items()) return fake_reporter(**kwargs) class TestBase(TestCase): @@ -207,7 +207,7 @@ class Test_mtime_watcher(mixins.TempDirMixin, TestCase): # and just severely crappy chance. # faster the io actions, easier it is to trigger. t = self.kls() - for x in xrange(100): + for x in range(100): now = ceil(time.time()) + 1 os.utime(self.dir, (now + 100, now + 100)) t.set_state([self.dir]) @@ -265,7 +265,7 @@ class Test_ldconfig(trigger_mixin, TestCase): self.assertPaths(self.trigger.read_ld_so_conf(self.dir), [pjoin(self.dir, x) for x in self.trigger.default_ld_path]) o = gen_obj(pjoin(self.dir, 'etc')) - self.assertEqual(o.mode, 0755) + self.assertEqual(o.mode, 0o755) self.assertTrue(fs.isdir(o)) self.assertTrue(os.path.exists(pjoin(self.dir, 'etc/ld.so.conf'))) @@ -395,8 +395,8 @@ END-INFO-DIR-ENTRY self.trigger._passed_in_args = [] self.engine.phase = phase self.trigger(self.engine, {}) - self.assertEqual(map(normpath, (x[1] for x in self.trigger._passed_in_args)), - map(normpath, expected_regen)) + self.assertEqual(list(map(normpath, (x[1] for x in self.trigger._passed_in_args))), + list(map(normpath, expected_regen))) return l def test_trigger(self): @@ -490,7 +490,7 @@ class single_attr_change_base(object): {'new_cset':new}) new = sorted(new) self.assertEqual(len(orig), len(new)) - for x, y in izip(orig, new): + for x, y in zip(orig, new): self.assertEqual(orig.__class__, new.__class__) for attr in x.__attrs__: if self.attr == attr: @@ -506,21 +506,21 @@ class single_attr_change_base(object): def test_trigger(self): self.assertContents() - self.assertContents([fs.fsFile("/foon", mode=0644, uid=2, gid=1, + self.assertContents([fs.fsFile("/foon", mode=0o644, uid=2, gid=1, strict=False)]) - self.assertContents([fs.fsFile("/foon", mode=0646, uid=1, gid=1, + self.assertContents([fs.fsFile("/foon", mode=0o646, uid=1, gid=1, strict=False)]) - self.assertContents([fs.fsFile("/foon", mode=04766, uid=1, gid=2, + self.assertContents([fs.fsFile("/foon", mode=0o4766, uid=1, gid=2, strict=False)]) - self.assertContents([fs.fsFile("/blarn", mode=02700, uid=2, gid=2, + self.assertContents([fs.fsFile("/blarn", mode=0o2700, uid=2, gid=2, strict=False), - fs.fsDir("/dir", mode=0500, uid=2, gid=2, strict=False)]) - self.assertContents([fs.fsFile("/blarn", mode=02776, uid=2, gid=2, + fs.fsDir("/dir", mode=0o500, uid=2, gid=2, strict=False)]) + self.assertContents([fs.fsFile("/blarn", mode=0o2776, uid=2, gid=2, strict=False), - fs.fsDir("/dir", mode=02777, uid=1, gid=2, strict=False)]) - self.assertContents([fs.fsFile("/blarn", mode=06772, uid=2, gid=2, + fs.fsDir("/dir", mode=0o2777, uid=1, gid=2, strict=False)]) + self.assertContents([fs.fsFile("/blarn", mode=0o6772, uid=2, gid=2, strict=False), - fs.fsDir("/dir", mode=04774, uid=1, gid=1, strict=False)]) + fs.fsDir("/dir", mode=0o4774, uid=1, gid=1, strict=False)]) class Test_fix_uid_perms(single_attr_change_base, TestCase): @@ -543,8 +543,8 @@ class Test_fix_set_bits(single_attr_change_base, TestCase): @staticmethod def good_val(val): - if val & 06000 and val & 0002: - return val & ~06002 + if val & 0o6000 and val & 0o002: + return val & ~0o6002 return val @@ -565,7 +565,7 @@ class Test_detect_world_writable(single_attr_change_base, TestCase): self.assertEqual(self._trigger_override, None, msg="bug in test code; good_val should not be invoked when a " "trigger override is in place.") - return val & ~0002 + return val & ~0o002 def test_lazyness(self): # ensure it doesn't even look if it won't make noise, and no reporter @@ -588,17 +588,17 @@ class Test_detect_world_writable(single_attr_change_base, TestCase): self.kls(fix_perms=fix_perms).trigger(engine, contentsSet(fs_objs)) - run([fs.fsFile('/foon', mode=0770, strict=False)]) + run([fs.fsFile('/foon', mode=0o770, strict=False)]) self.assertFalse(warnings) - run([fs.fsFile('/foon', mode=0772, strict=False)]) + run([fs.fsFile('/foon', mode=0o772, strict=False)]) self.assertEqual(len(warnings), 1) self.assertIn('/foon', warnings[0]) warnings[:] = [] - run([fs.fsFile('/dar', mode=0776, strict=False), - fs.fsFile('/bar', mode=0776, strict=False), - fs.fsFile('/far', mode=0770, strict=False)]) + run([fs.fsFile('/dar', mode=0o776, strict=False), + fs.fsFile('/bar', mode=0o776, strict=False), + fs.fsFile('/far', mode=0o770, strict=False)]) self.assertEqual(len(warnings), 2) self.assertIn('/dar', ' '.join(warnings)) diff --git a/tests/merge/util.py b/tests/merge/util.py index 170b249b..e708ec72 100644 --- a/tests/merge/util.py +++ b/tests/merge/util.py @@ -10,9 +10,9 @@ class fake_trigger(triggers.base): def __init__(self, **kwargs): self._called = [] - if isinstance(kwargs.get('_hooks', False), basestring): + if isinstance(kwargs.get('_hooks', False), str): kwargs['_hooks'] = (kwargs['_hooks'],) - for k, v in kwargs.iteritems(): + for k, v in kwargs.items(): if callable(v): v = partial(v, self) setattr(self, k, v) @@ -26,7 +26,7 @@ class fake_engine(object): def __init__(self, **kwargs): kwargs.setdefault('observer', None) self._triggers = [] - for k, v in kwargs.iteritems(): + for k, v in kwargs.items(): if callable(v): v = partial(v, self) setattr(self, k, v) @@ -39,5 +39,5 @@ class fake_engine(object): class fake_reporter(object): def __init__(self, **kwargs): - for k, v in kwargs.iteritems(): + for k, v in kwargs.items(): setattr(self, k, v) diff --git a/tests/package/__init__.py b/tests/package/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/package/__init__.py diff --git a/tests/package/test_base.py b/tests/package/test_base.py index cac6b8e1..21438275 100644 --- a/tests/package/test_base.py +++ b/tests/package/test_base.py @@ -49,12 +49,12 @@ class TestBasePkg(mixin, TestCase): class Class(base.base): __slotting_intentionally_disabled__ = True _get_attr = {str(x): partial((lambda a, s: a), x) - for x in xrange(10)} + for x in range(10)} _get_attr["a"] = lambda s:"foo" __getattr__ = base.dynamic_getattr_dict o = Class() - for x in xrange(10): + for x in range(10): self.assertEqual(getattr(o, str(x)), x) self.assertEqual(o.a, "foo") self.assertEqual(self.mk_inst().built, False) diff --git a/tests/package/test_mutated.py b/tests/package/test_mutated.py index 2bd13b25..fe7cc272 100644 --- a/tests/package/test_mutated.py +++ b/tests/package/test_mutated.py @@ -23,7 +23,7 @@ class FakePkg(base): base.__init__(self) self.pkg = pkg self.ver = ver - self._get_attr = {k: partial(passthru, v) for k, v in data.iteritems()} + self._get_attr = {k: partial(passthru, v) for k, v in data.items()} # disable protection. don't want it here __setattr__ = object.__setattr__ diff --git a/tests/pkgsets/__init__.py b/tests/pkgsets/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/pkgsets/__init__.py diff --git a/tests/pkgsets/test_filelist.py b/tests/pkgsets/test_filelist.py index b66a474e..5fab8ef0 100644 --- a/tests/pkgsets/test_filelist.py +++ b/tests/pkgsets/test_filelist.py @@ -58,7 +58,7 @@ class TestFileList(TestCase): s.add(atom("=dev-util/lib-1")) s.flush() with open(self.fn) as f: - self.assertEqual(map(atom, (x.strip() for x in f)), + self.assertEqual(list(map(atom, (x.strip() for x in f))), sorted(map(atom, ("dev-util/diffball", "=dev-util/bsdiff-0.4", "dev-util/foon", "=dev-util/lib-1")))) diff --git a/tests/pkgsets/test_glsa.py b/tests/pkgsets/test_glsa.py index fe4cbf4c..304cfa3e 100644 --- a/tests/pkgsets/test_glsa.py +++ b/tests/pkgsets/test_glsa.py @@ -54,8 +54,8 @@ glsa_template = \ """ ops = {'>':'gt', '<':'lt'} -ops.update((k+'=', v[0] + 'e') for k, v in ops.items()) -ops.update(('~' + k, 'r' + v) for k, v in ops.items()) +ops.update((k+'=', v[0] + 'e') for k, v in list(ops.items())) +ops.update(('~' + k, 'r' + v) for k, v in list(ops.items())) ops['='] = 'eq' def convert_range(text, tag): i = 0 diff --git a/tests/repository/__init__.py b/tests/repository/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/repository/__init__.py diff --git a/tests/repository/test_filtered.py b/tests/repository/test_filtered.py index 083efa0d..a7258b56 100644 --- a/tests/repository/test_filtered.py +++ b/tests/repository/test_filtered.py @@ -5,7 +5,7 @@ from pkgcore.ebuild.atom import atom from pkgcore.ebuild.cpv import versioned_CPV from pkgcore.repository import filtered from pkgcore.restrictions import packages, values -from pkgcore.test.repository.test_prototype import SimpleTree +from pkgcore.repository.util import SimpleTree from snakeoil.test import TestCase diff --git a/tests/repository/test_multiplex.py b/tests/repository/test_multiplex.py index 16e583d6..4371344f 100644 --- a/tests/repository/test_multiplex.py +++ b/tests/repository/test_multiplex.py @@ -34,10 +34,10 @@ class TestMultiplex(TestCase): self.d2.setdefault(cat, {}).setdefault(pkg, []).extend(ver) self.d1 = OrderedDict( - (k, OrderedDict(self.d1[k].iteritems())) + (k, OrderedDict(self.d1[k].items())) for k in sorted(self.d1, reverse=True)) self.d2 = OrderedDict( - (k, OrderedDict(self.d2[k].iteritems())) + (k, OrderedDict(self.d2[k].items())) for k in sorted(self.d2, reverse=True)) self.tree1 = SimpleTree(self.d1) self.tree2 = SimpleTree(self.d2) diff --git a/tests/repository/test_prototype.py b/tests/repository/test_prototype.py index 79f473ea..da1defe1 100644 --- a/tests/repository/test_prototype.py +++ b/tests/repository/test_prototype.py @@ -30,7 +30,7 @@ class TestPrototype(TestCase): def test_concurrent_access(self): iall = iter(self.repo) self.repo.match(atom("dev-lib/fake")) - pkg = iall.next() + pkg = next(iall) if pkg.category == 'dev-util': self.repo.match(atom("dev-lib/fake")) else: @@ -48,7 +48,7 @@ class TestPrototype(TestCase): self.assertEqual( sorted( "%s/%s-%s" % (cp[0], cp[1], v) - for cp, t in self.repo.versions.iteritems() for v in t), + for cp, t in self.repo.versions.items() for v in t), sorted([ "dev-util/diffball-1.0", "dev-util/diffball-0.7", "dev-util/bsdiff-0.4.1", "dev-util/bsdiff-0.4.2", diff --git a/tests/resolver/__init__.py b/tests/resolver/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/resolver/__init__.py diff --git a/tests/resolver/test_pigeonholes.py b/tests/resolver/test_pigeonholes.py index 197dab58..e58a3312 100644 --- a/tests/resolver/test_pigeonholes.py +++ b/tests/resolver/test_pigeonholes.py @@ -3,8 +3,8 @@ from pkgcore.resolver.pigeonholes import PigeonHoledSlots from pkgcore.restrictions import restriction -from pkgcore.test.resolver.test_choice_point import fake_package from snakeoil.test import TestCase +from tests.resolver.test_choice_point import fake_package class fake_blocker(restriction.base): diff --git a/tests/restrictions/__init__.py b/tests/restrictions/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/restrictions/__init__.py diff --git a/tests/restrictions/test_boolean.py b/tests/restrictions/test_boolean.py index 37099ae3..21de2534 100644 --- a/tests/restrictions/test_boolean.py +++ b/tests/restrictions/test_boolean.py @@ -114,9 +114,9 @@ class AndRestrictionTest(base, TestCase): self.kls(true, true), true).dnf_solutions(), [[true, true, true]]) self.assertEqual( - map(set, self.kls( + list(map(set, self.kls( true, true, - boolean.OrRestriction(false, true)).dnf_solutions()), + boolean.OrRestriction(false, true)).dnf_solutions())), [set([true, true, false]), set([true, true, true])]) self.assertEqual(self.kls().dnf_solutions(), [[]]) @@ -164,10 +164,10 @@ class OrRestrictionTest(base, TestCase): self.kls(true, true).dnf_solutions(), [[true], [true]]) self.assertEqual( - map(set, self.kls( + list(map(set, self.kls( true, true, - boolean.AndRestriction(false, true)).dnf_solutions()), - map(set, [[true], [true], [false, true]])) + boolean.AndRestriction(false, true)).dnf_solutions())), + list(map(set, [[true], [true], [false, true]]))) self.assertEqual( self.kls( self.kls(true, false), true).dnf_solutions(), diff --git a/tests/restrictions/test_util.py b/tests/restrictions/test_util.py index c846630e..fd6d429b 100644 --- a/tests/restrictions/test_util.py +++ b/tests/restrictions/test_util.py @@ -22,13 +22,13 @@ class Test_collect_package_restrictions(TestCase): r = packages.AndRestriction( packages.OrRestriction(*prs.values()), packages.AlwaysTrue) - for k, v in prs.iteritems(): + for k, v in prs.items(): self.assertEqual( list(util.collect_package_restrictions(r, attrs=[k])), [v]) r = packages.AndRestriction(packages.OrRestriction( *prs.values()), *prs.values()) - for k, v in prs.iteritems(): + for k, v in prs.items(): self.assertEqual( list(util.collect_package_restrictions(r, attrs=[k])), [v] * 2) diff --git a/tests/restrictions/test_values.py b/tests/restrictions/test_values.py index 6216153a..a35bab88 100644 --- a/tests/restrictions/test_values.py +++ b/tests/restrictions/test_values.py @@ -164,7 +164,7 @@ class cpy_TestStrExactMatch(native_TestStrExactMatch): def test_eq_isinstance_checks(self): # this seems insane, but it's the right alloc to trigger it - self.kls("", case_sensitive=False).__ne__(u"\uEFA3\uC2EF\uBE5B\u9D98\uFE2F\uB781\u27C7\u8592") + self.kls("", case_sensitive=False).__ne__("\uEFA3\uC2EF\uBE5B\u9D98\uFE2F\uB781\u27C7\u8592") class TestStrGlobMatch(TestRestriction): @@ -241,7 +241,7 @@ class TestEqualityMatch(TestRestriction): for x, y, ret in (("asdf", "asdf", True), ("asdf", "fdsa", False), (1, 1, True), (1,2, False), (list(range(2)), list(range(2)), True), - (range(2), reversed(range(2)), False), + (list(range(2)), reversed(list(range(2))), False), (True, True, True), (True, False, False), (False, True, False)): @@ -278,10 +278,10 @@ class TestContainmentMatch(TestRestriction): def test_match(self): for x, y, ret in ( - (range(10), range(10), True), - (range(10), [], False), - (range(10), set(xrange(10)), True), - (set(xrange(10)), range(10), True)): + (list(range(10)), list(range(10)), True), + (list(range(10)), [], False), + (list(range(10)), set(range(10)), True), + (set(range(10)), list(range(10)), True)): for negated in (False, True): self.assertMatches(self.kls(negate=negated, @@ -292,10 +292,9 @@ class TestContainmentMatch(TestRestriction): # intentionally differing for the force_* args; slips in # an extra data set for testing. self.assertMatches(self.kls(all=True, negate=negated, *range(10)), - range(20), [range(10)]*3, negated=negated) - self.assertNotMatches(self.kls(all=True, negate=negated, - *range(10)), - range(5), [range(5)]*3, negated=negated) + list(range(20)), [list(range(10))]*3, negated=negated) + self.assertNotMatches(self.kls(all=True, negate=negated, *range(10)), + list(range(5)), [list(range(5))]*3, negated=negated) self.assertNotMatches(self.kls("asdf"), "fdsa", ["fdas"]*3) self.assertMatches(self.kls("asdf"), "asdf", ["asdf"]*3) @@ -361,5 +360,5 @@ class AnyMatchTest(TestCase): def test_force(self): restrict = values.AnyMatch(values.AlwaysTrue) - self.assertTrue(restrict.force_True(None, None, range(2))) - self.assertFalse(restrict.force_False(None, None, range(2))) + self.assertTrue(restrict.force_True(None, None, list(range(2)))) + self.assertFalse(restrict.force_False(None, None, list(range(2)))) diff --git a/tests/scripts/__init__.py b/tests/scripts/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/scripts/__init__.py diff --git a/tests/scripts/test_filter_env.py b/tests/scripts/test_filter_env.py index 69c8ad48..4a2cf9be 100644 --- a/tests/scripts/test_filter_env.py +++ b/tests/scripts/test_filter_env.py @@ -3,7 +3,7 @@ # License: BSD/GPL2 from pkgcore.scripts import filter_env -from pkgcore.test.scripts.helpers import ArgParseMixin +from tests.scripts.helpers import ArgParseMixin from snakeoil.test import TestCase diff --git a/tests/scripts/test_pclean.py b/tests/scripts/test_pclean.py index 620daa81..a98269a8 100644 --- a/tests/scripts/test_pclean.py +++ b/tests/scripts/test_pclean.py @@ -2,7 +2,7 @@ # License: BSD/GPL2 from pkgcore.scripts import pclean -from pkgcore.test.scripts.helpers import ArgParseMixin +from tests.scripts.helpers import ArgParseMixin from snakeoil.test import TestCase diff --git a/tests/scripts/test_pclonecache.py b/tests/scripts/test_pclonecache.py index e546c32e..8fff8fbf 100644 --- a/tests/scripts/test_pclonecache.py +++ b/tests/scripts/test_pclonecache.py @@ -3,7 +3,7 @@ from pkgcore.config import basics, ConfigHint from pkgcore.scripts import pclonecache -from pkgcore.test.scripts.helpers import ArgParseMixin +from tests.scripts.helpers import ArgParseMixin from snakeoil.test import TestCase diff --git a/tests/scripts/test_pconfig.py b/tests/scripts/test_pconfig.py index cb4ffdf7..10a20495 100644 --- a/tests/scripts/test_pconfig.py +++ b/tests/scripts/test_pconfig.py @@ -7,7 +7,7 @@ from snakeoil.test import TestCase from pkgcore.config import configurable, basics, errors from pkgcore.scripts import pconfig -from pkgcore.test.scripts.helpers import ArgParseMixin +from tests.scripts.helpers import ArgParseMixin @configurable({'reff': 'ref:spork'}) @@ -67,19 +67,19 @@ class DescribeClassTest(TestCase, ArgParseMixin): 'Test thing.', '', 'reff: ref:spork (required)'], - 'pkgcore.test.scripts.test_pconfig.spork') + 'tests.scripts.test_pconfig.spork') self.assertOut( ['typename is increment', 'Noop.', 'values not listed are handled as strings', '', 'inc: list'], - 'pkgcore.test.scripts.test_pconfig.increment') + 'tests.scripts.test_pconfig.increment') def test_broken_type(self): self.assertErr( ['Not a valid type!'], - 'pkgcore.test.scripts.test_pconfig.broken_type') + 'tests.scripts.test_pconfig.broken_type') class ClassesTest(TestCase, ArgParseMixin): @@ -88,25 +88,25 @@ class ClassesTest(TestCase, ArgParseMixin): def test_classes(self): sections = [] - for i in xrange(10): + for i in range(10): @configurable(typename='spork') def noop(): """noop""" noop.__name__ = str(i) sections.append(basics.HardCodedConfigSection({'class': noop})) self.assertOut( - ['pkgcore.test.scripts.test_pconfig.foon'], + ['tests.scripts.test_pconfig.foon'], spork=basics.HardCodedConfigSection({'class': foon})) self.assertOut([ - 'pkgcore.test.scripts.test_pconfig.0', - 'pkgcore.test.scripts.test_pconfig.1', - 'pkgcore.test.scripts.test_pconfig.2', - 'pkgcore.test.scripts.test_pconfig.3', - 'pkgcore.test.scripts.test_pconfig.4', - 'pkgcore.test.scripts.test_pconfig.5', - 'pkgcore.test.scripts.test_pconfig.multi', - 'pkgcore.test.scripts.test_pconfig.pseudospork', - 'pkgcore.test.scripts.test_pconfig.spork', + 'tests.scripts.test_pconfig.0', + 'tests.scripts.test_pconfig.1', + 'tests.scripts.test_pconfig.2', + 'tests.scripts.test_pconfig.3', + 'tests.scripts.test_pconfig.4', + 'tests.scripts.test_pconfig.5', + 'tests.scripts.test_pconfig.multi', + 'tests.scripts.test_pconfig.pseudospork', + 'tests.scripts.test_pconfig.spork', ], bork=basics.HardCodedConfigSection({ 'class': pseudospork, 'bork': True, 'inherit-only': True}), @@ -132,7 +132,7 @@ class DumpTest(TestCase, ArgParseMixin): self.assertOut( ["'spork' {", ' # typename of this section: foon', - ' class pkgcore.test.scripts.test_pconfig.foon;', + ' class tests.scripts.test_pconfig.foon;', '}', ''], spork=basics.HardCodedConfigSection({'class': foon})) @@ -141,7 +141,7 @@ class DumpTest(TestCase, ArgParseMixin): self.assertOut( ["'spork' {", ' # typename of this section: foon', - ' class pkgcore.test.scripts.test_pconfig.foon;', + ' class tests.scripts.test_pconfig.foon;', ' default true;', '}', ''], @@ -159,38 +159,38 @@ class DumpTest(TestCase, ArgParseMixin): self.assertOut( ["'spork' {", ' # typename of this section: multi', - ' class pkgcore.test.scripts.test_pconfig.multi;', + ' class tests.scripts.test_pconfig.multi;', ' # type: bool', ' boolean True;', ' # type: callable', - ' callable pkgcore.test.scripts.test_pconfig.multi;', + ' callable tests.scripts.test_pconfig.multi;', ' # type: lazy_ref:spork', ' lazy_ref {', ' # typename of this section: spork', - ' class pkgcore.test.scripts.test_pconfig.pseudospork;', + ' class tests.scripts.test_pconfig.pseudospork;', ' };', ' # type: lazy_refs:spork', ' lazy_refs {', ' # typename of this section: spork', - ' class pkgcore.test.scripts.test_pconfig.pseudospork;', + ' class tests.scripts.test_pconfig.pseudospork;', ' } {', ' # typename of this section: spork', - ' class pkgcore.test.scripts.test_pconfig.pseudospork;', + ' class tests.scripts.test_pconfig.pseudospork;', ' };', ' # type: list', " list 'a' 'b\\' \"c';", ' # type: ref:spork', ' ref {', ' # typename of this section: spork', - ' class pkgcore.test.scripts.test_pconfig.pseudospork;', + ' class tests.scripts.test_pconfig.pseudospork;', ' };', ' # type: refs:spork', ' refs {', ' # typename of this section: spork', - ' class pkgcore.test.scripts.test_pconfig.pseudospork;', + ' class tests.scripts.test_pconfig.pseudospork;', ' } {', ' # typename of this section: spork', - ' class pkgcore.test.scripts.test_pconfig.pseudospork;', + ' class tests.scripts.test_pconfig.pseudospork;', ' };', ' # type: str', ' string \'it is a "stringy" \\\'string\\\'\';', @@ -215,7 +215,7 @@ class DumpTest(TestCase, ArgParseMixin): self.assertOut( ["'spork' {", ' # typename of this section: spork', - ' class pkgcore.test.scripts.test_pconfig.pseudospork;', + ' class tests.scripts.test_pconfig.pseudospork;', '}', '', ], @@ -238,7 +238,7 @@ class UncollapsableTest(TestCase, ArgParseMixin): "", "section spork:", " Collapsing section named 'spork'", - " type pkgcore.test.scripts.test_pconfig.spork needs settings for 'reff'" + " type tests.scripts.test_pconfig.spork needs settings for 'reff'" "", "", ], @@ -297,7 +297,7 @@ class DumpUncollapsedTest(TestCase, ArgParseMixin): 'foon', '====', '# type: callable', - "'class' = pkgcore.test.scripts.test_pconfigspork", + "'class' = tests.scripts.test_pconfigspork", '# type: bool', "'inherit-only' = True", '# type: refs', @@ -329,7 +329,7 @@ class DumpUncollapsedTest(TestCase, ArgParseMixin): 'spork', '=====', '# type: callable', - "'class' = pkgcore.test.scripts.test_pconfigspork", + "'class' = tests.scripts.test_pconfigspork", '', ], spork=basics.HardCodedConfigSection({'class': spork}), diff --git a/tests/scripts/test_pebuild.py b/tests/scripts/test_pebuild.py index 2bd58046..16ffb879 100644 --- a/tests/scripts/test_pebuild.py +++ b/tests/scripts/test_pebuild.py @@ -4,7 +4,7 @@ from pkgcore.config import basics, ConfigHint, configurable from pkgcore.scripts import pebuild from pkgcore.test.misc import FakePkg, FakeRepo -from pkgcore.test.scripts.helpers import ArgParseMixin +from tests.scripts.helpers import ArgParseMixin from snakeoil.test import TestCase diff --git a/tests/scripts/test_pmaint.py b/tests/scripts/test_pmaint.py index f37f768d..e2bb198d 100644 --- a/tests/scripts/test_pmaint.py +++ b/tests/scripts/test_pmaint.py @@ -15,7 +15,7 @@ from pkgcore.operations.repo import install, uninstall, replace, operations from pkgcore.repository import util, syncable from pkgcore.scripts import pmaint from pkgcore.sync import base -from pkgcore.test.scripts.helpers import ArgParseMixin +from tests.scripts.helpers import ArgParseMixin @@ -168,7 +168,7 @@ class fake_pkg(CPV): object.__setattr__(self, 'repo', repo) def derive_op(name, op, *a, **kw): - if isinstance(name, basestring): + if isinstance(name, str): name = [name] name = ['finalize_data'] + list(name) class new_op(op): @@ -198,7 +198,7 @@ class TestCopy(TestCase, ArgParseMixin): domain=make_domain(vdb={'sys-apps':{'portage':['2.1', '2.3']}}), ) self.assertEqual(ret, 0, "expected non zero exit code") - self.assertEqual(map(str, config.target_repo.installed), + self.assertEqual(list(map(str, config.target_repo.installed)), ['sys-apps/portage-2.1', 'sys-apps/portage-2.3']) self.assertEqual(config.target_repo.uninstalled, config.target_repo.replaced, @@ -211,7 +211,7 @@ class TestCopy(TestCase, ArgParseMixin): domain=make_domain(binpkg=d, vdb=d), ) self.assertEqual(ret, 0, "expected non zero exit code") - self.assertEqual([map(str, x) for x in config.target_repo.replaced], + self.assertEqual([list(map(str, x)) for x in config.target_repo.replaced], [['sys-apps/portage-2.1', 'sys-apps/portage-2.1']]) self.assertEqual(config.target_repo.uninstalled, config.target_repo.installed, @@ -224,7 +224,7 @@ class TestCopy(TestCase, ArgParseMixin): domain=make_domain(vdb={'sys-apps':{'portage':['2.1', '2.3']}}), ) self.assertEqual(ret, 0, "expected non zero exit code") - self.assertEqual(map(str, config.target_repo.installed), + self.assertEqual(list(map(str, config.target_repo.installed)), ['sys-apps/portage-2.1', 'sys-apps/portage-2.3']) self.assertEqual(config.target_repo.uninstalled, config.target_repo.replaced, @@ -238,7 +238,7 @@ class TestCopy(TestCase, ArgParseMixin): vdb={'sys-apps':{'portage':['2.1', '2.3']}}), ) self.assertEqual(ret, 0, "expected non zero exit code") - self.assertEqual(map(str, config.target_repo.installed), + self.assertEqual(list(map(str, config.target_repo.installed)), ['sys-apps/portage-2.3']) self.assertEqual(config.target_repo.uninstalled, config.target_repo.replaced, diff --git a/tests/scripts/test_pmerge.py b/tests/scripts/test_pmerge.py index f043cfaf..32a15dd5 100644 --- a/tests/scripts/test_pmerge.py +++ b/tests/scripts/test_pmerge.py @@ -43,12 +43,12 @@ class TargetParsingTest(TestCase): pmerge.AmbiguousQuery, pmerge.parse_target, parse_match("foon"), repo, installed_repos) # test unicode conversion. - a = pmerge.parse_target(parse_match(u'=spork/foon-1'), repo, installed_repos) + a = pmerge.parse_target(parse_match('=spork/foon-1'), repo, installed_repos) self.assertEqual(len(a), 1) self.assertEqual(a[0].key, 'spork/foon') self.assertTrue(isinstance(a[0].key, str)) # test globbing - a = pmerge.parse_target(parse_match(u'*/foon'), repo, installed_repos) + a = pmerge.parse_target(parse_match('*/foon'), repo, installed_repos) self.assertEqual(len(a), 2) # test pkg name collisions between real and virtual pkgs in a repo, but not installed diff --git a/tests/scripts/test_pplugincache.py b/tests/scripts/test_pplugincache.py index 91283ee2..23741c31 100644 --- a/tests/scripts/test_pplugincache.py +++ b/tests/scripts/test_pplugincache.py @@ -3,7 +3,7 @@ from pkgcore import plugins from pkgcore.scripts import pplugincache -from pkgcore.test.scripts.helpers import ArgParseMixin +from tests.scripts.helpers import ArgParseMixin from snakeoil.test import TestCase diff --git a/tests/scripts/test_pquery.py b/tests/scripts/test_pquery.py index d4494b28..da034abb 100644 --- a/tests/scripts/test_pquery.py +++ b/tests/scripts/test_pquery.py @@ -6,7 +6,7 @@ from pkgcore.config import basics, ConfigHint, configurable from pkgcore.ebuild import atom from pkgcore.repository import util from pkgcore.scripts import pquery -from pkgcore.test.scripts.helpers import ArgParseMixin +from tests.scripts.helpers import ArgParseMixin from snakeoil.test import TestCase diff --git a/tests/sync/__init__.py b/tests/sync/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/sync/__init__.py diff --git a/tests/sync/test_base.py b/tests/sync/test_base.py index 5dff08c7..f673e3e2 100644 --- a/tests/sync/test_base.py +++ b/tests/sync/test_base.py @@ -5,7 +5,7 @@ import os import pwd from pkgcore.sync import base, svn -from pkgcore.test.sync import make_bogus_syncer, make_valid_syncer +from tests.sync.syncer import make_bogus_syncer, make_valid_syncer from snakeoil.test import TestCase, SkipTest valid = make_valid_syncer(base.ExternalSyncer) diff --git a/tests/sync/test_bzr.py b/tests/sync/test_bzr.py index 0fb84c98..99eb948f 100644 --- a/tests/sync/test_bzr.py +++ b/tests/sync/test_bzr.py @@ -2,7 +2,7 @@ # License: GPL2/BSD from pkgcore.sync import base, bzr -from pkgcore.test.sync import make_bogus_syncer, make_valid_syncer +from tests.sync.syncer import make_bogus_syncer, make_valid_syncer from snakeoil.test import TestCase bogus = make_bogus_syncer(bzr.bzr_syncer) diff --git a/tests/sync/test_cvs.py b/tests/sync/test_cvs.py index 250f2832..401504f8 100644 --- a/tests/sync/test_cvs.py +++ b/tests/sync/test_cvs.py @@ -2,7 +2,7 @@ # License: GPL2/BSD from pkgcore.sync import base, cvs -from pkgcore.test.sync import make_bogus_syncer, make_valid_syncer +from tests.sync.syncer import make_bogus_syncer, make_valid_syncer from snakeoil.test import TestCase bogus = make_bogus_syncer(cvs.cvs_syncer) diff --git a/tests/sync/test_darcs.py b/tests/sync/test_darcs.py index a1309077..32d2f2fd 100644 --- a/tests/sync/test_darcs.py +++ b/tests/sync/test_darcs.py @@ -2,7 +2,7 @@ # License: GPL2/BSD from pkgcore.sync import base, darcs -from pkgcore.test.sync import make_bogus_syncer, make_valid_syncer +from tests.sync.syncer import make_bogus_syncer, make_valid_syncer from snakeoil.test import TestCase bogus = make_bogus_syncer(darcs.darcs_syncer) diff --git a/tests/sync/test_git.py b/tests/sync/test_git.py index f9d9626b..e1cfa4e7 100644 --- a/tests/sync/test_git.py +++ b/tests/sync/test_git.py @@ -2,7 +2,7 @@ # License: GPL2/BSD from pkgcore.sync import base, git -from pkgcore.test.sync import make_bogus_syncer, make_valid_syncer +from tests.sync.syncer import make_bogus_syncer, make_valid_syncer from snakeoil.test import TestCase bogus = make_bogus_syncer(git.git_syncer) diff --git a/tests/sync/test_git_svn.py b/tests/sync/test_git_svn.py index f5a1a9d7..c7f252dd 100644 --- a/tests/sync/test_git_svn.py +++ b/tests/sync/test_git_svn.py @@ -3,7 +3,7 @@ # License: GPL2/BSD from pkgcore.sync import base, git_svn -from pkgcore.test.sync import make_bogus_syncer, make_valid_syncer +from tests.sync.syncer import make_bogus_syncer, make_valid_syncer from snakeoil.test import TestCase bogus = make_bogus_syncer(git_svn.git_svn_syncer) diff --git a/tests/sync/test_hg.py b/tests/sync/test_hg.py index 4deda546..fc8285d7 100644 --- a/tests/sync/test_hg.py +++ b/tests/sync/test_hg.py @@ -2,7 +2,7 @@ # License: GPL2/BSD from pkgcore.sync import base, hg -from pkgcore.test.sync import make_bogus_syncer, make_valid_syncer +from tests.sync.syncer import make_bogus_syncer, make_valid_syncer from snakeoil.test import TestCase bogus = make_bogus_syncer(hg.hg_syncer) diff --git a/tests/sync/test_rsync.py b/tests/sync/test_rsync.py index e67d4721..b81bcd63 100644 --- a/tests/sync/test_rsync.py +++ b/tests/sync/test_rsync.py @@ -2,7 +2,7 @@ # License: GPL2/BSD from pkgcore.sync import base, rsync -from pkgcore.test.sync import make_bogus_syncer, make_valid_syncer +from tests.sync.syncer import make_bogus_syncer, make_valid_syncer from snakeoil.test import TestCase bogus = make_bogus_syncer(rsync.rsync_syncer) diff --git a/tests/sync/test_svn.py b/tests/sync/test_svn.py index aebd257d..2cfd7cc0 100644 --- a/tests/sync/test_svn.py +++ b/tests/sync/test_svn.py @@ -2,7 +2,7 @@ # License: GPL2/BSD from pkgcore.sync import base, svn -from pkgcore.test.sync import make_bogus_syncer, make_valid_syncer +from tests.sync.syncer import make_bogus_syncer, make_valid_syncer from snakeoil.test import TestCase bogus = make_bogus_syncer(svn.svn_syncer) diff --git a/tests/test_del_usage.py b/tests/test_del_usage.py deleted file mode 100644 index 9f701630..00000000 --- a/tests/test_del_usage.py +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright: 2010 Brian Harring <ferringb@gmail.com> -# License: GPL2/BSD 3 clause - -from snakeoil.test import test_del_usage as module - - -class Test(module.Test): - - target_namespace = "pkgcore" - ignore_all_import_failures = True diff --git a/tests/test_plugin.py b/tests/test_plugin.py index b667c0dd..485076b1 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -54,7 +54,7 @@ pkgcore_plugins = { 'plugtest': [ DisabledPlug, high_plug, - 'pkgcore.test.test_plugin.LowPlug', + 'tests.test_plugin.LowPlug', ] } ''') @@ -133,7 +133,7 @@ pkgcore_plugins = {'plugtest': [HiddenPlug]} self.assertEqual('plug2:%s:\n' % (mtime,), lines[0]) mtime = int(os.path.getmtime(pjoin(self.packdir, 'plug.py'))) self.assertEqual( - 'plug:%s:plugtest,7,1:plugtest,1,pkgcore.test.test_plugin.LowPlug:' + 'plug:%s:plugtest,7,1:plugtest,1,tests.test_plugin.LowPlug:' 'plugtest,0,0\n' % (mtime,), lines[1]) diff --git a/tests/test_slot_shadowing.py b/tests/test_slot_shadowing.py index 195352c3..42d85b3a 100644 --- a/tests/test_slot_shadowing.py +++ b/tests/test_slot_shadowing.py @@ -1,10 +1,10 @@ # Copyright: 2009 Brian Harring <ferringb@gmail.com> # License: GPL2/BSD -from snakeoil.test import test_slot_shadowing +from snakeoil.test.slot_shadowing import SlotShadowing -class Test_slot_shadowing(test_slot_shadowing.Test_slot_shadowing): +class Test_slot_shadowing(SlotShadowing): target_namespace = "pkgcore" ignore_all_import_failures = True diff --git a/tests/test_source_hygene.py b/tests/test_source_hygene.py index f05c4417..af6b2a59 100644 --- a/tests/test_source_hygene.py +++ b/tests/test_source_hygene.py @@ -1,14 +1,15 @@ # Copyright: 2006 Brian Harring <ferringb@gmail.com> # License: GPL2/BSD -from snakeoil.test import test_demandload_usage, test_source_hygene +from snakeoil.test.demandload import DemandLoadTargets +from snakeoil.test.modules import ExportedModules -class TestDemandLoadUsage(test_demandload_usage.TestDemandLoadTargets): +class TestDemandLoadUsage(DemandLoadTargets): target_namespace = "pkgcore" ignore_all_import_failures = True -class Test_modules(test_source_hygene.Test_modules): +class Test_modules(ExportedModules): target_namespace = 'pkgcore' ignore_all_import_failures = True diff --git a/tests/util/__init__.py b/tests/util/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/util/__init__.py diff --git a/tests/util/test_commandline.py b/tests/util/test_commandline.py index c7cfd4b9..2503661a 100644 --- a/tests/util/test_commandline.py +++ b/tests/util/test_commandline.py @@ -11,7 +11,7 @@ import sys import unittest from pkgcore.config import central, errors -from pkgcore.test.scripts.helpers import ArgParseMixin +from tests.scripts.helpers import ArgParseMixin from pkgcore.util import commandline from snakeoil.test import TestCase @@ -62,15 +62,15 @@ class ModifyConfigTest(TestCase, ArgParseMixin): def test_modify_config(self): namespace = self.parse( '--empty-config', '--new-config', - 'foo', 'class', 'pkgcore.test.util.test_commandline.sect', + 'foo', 'class', 'tests.util.test_commandline.sect', '--trigger') self.assertTrue(namespace.config.collapse_named_section('foo')) namespace = self.parse( '--empty-config', '--new-config', - 'foo', 'class', 'pkgcore.test.util.test_commandline.missing', + 'foo', 'class', 'tests.util.test_commandline.missing', '--add-config', 'foo', 'class', - 'pkgcore.test.util.test_commandline.sect', + 'tests.util.test_commandline.sect', '--trigger') self.assertTrue(namespace.config.collapse_named_section('foo')) |