def loadRecipe(repos, name, version, flavor, trv, defaultFlavor=None, loadInstalledSource=None, installLabelPath=None, buildLabel=None, groupRecipeSource=None, cfg=None): name = name.split(':')[0] try: if defaultFlavor is not None: fullFlavor = deps.overrideFlavor(defaultFlavor, flavor) else: fullFlavor = flavor # set up necessary flavors and track used flags before # calling loadRecipe, since even loading the class # may check some flags that may never be checked inside # the recipe recipeObj, loader = getRecipeObj(repos, name, version, fullFlavor, trv, loadInstalledSource=loadInstalledSource, installLabelPath=installLabelPath, buildLabel=buildLabel, cfg=cfg) relevantFlavor = use.usedFlagsToFlavor(recipeObj.name) relevantFlavor = flavorutil.removeInstructionSetFlavor(relevantFlavor) # always add in the entire arch flavor. We need to ensure the # relevant flavor is unique per architecture, also, arch flavors # can affect the macros used. if defaultFlavor is not None: relevantFlavor.union(flavor) relevantFlavor.union(flavorutil.getArchFlags(fullFlavor)) relevantFlags = flavorutil.getFlavorUseFlags(relevantFlavor) flags = flavorutil.getFlavorUseFlags(fullFlavor) use.track(False) for flagSet in ('Use',): # allow local flags not to be used -- they are set to their default if flagSet not in relevantFlags: continue for flag in relevantFlags[flagSet]: if flag not in flags[flagSet]: raise (RuntimeError, "Recipe %s uses Flavor %s but value not known" %(name, flag)) if 'Arch' in relevantFlags: for majarch in relevantFlags['Arch'].keys(): for subarch in relevantFlags['Arch'][majarch]: if not use.Arch[majarch][subarch]: #negative values for subarches are assumed continue if subarch not in flags['Arch'][majarch]: log.error("arch %s.%s used but not specified" % ( majarch, subarch)) raise RuntimeError, ( "arch %s.%s used but not specified" % ( majarch, subarch)) use.resetUsed() except: log.error('Error Loading Recipe (%s, %s, %s):\n%s' % (name, version, fullFlavor, ''.join(traceback.format_exc()))) raise return loader, recipeObj, relevantFlavor
def testLoadedTroves(self): # we don't check the output of this test. self.logFilter.add() repos = self.openRepository() header = ''' if Use.%s: foo = '1.0-readline' else: foo = '1.0-noreadline' ''' self.addTestPkg(1, version='1.0', header=header % 'readline') self.addTestPkg(2, header='loadRecipe("test1")' + header % 'ssl') test3Recipe = self.addTestPkg(3, header='loadRecipe("test2")' + header % 'bootstrap') use.track() rldep = deps.parseFlavor('readline') ssldep = deps.parseFlavor('ssl') nobsdep = deps.parseFlavor('~!bootstrap') v1 = versions.VersionFromString('/localhost@rpl:linux/1.0-1') loader = self._testSubload(repos, "loadInstalled('test3')") FooLoaded = loader.getLoadedSpecs() assert (FooLoaded['test3'][0] == ('test3:source', v1, nobsdep)) Test3Loaded = FooLoaded['test3'][1] assert (Test3Loaded['test2'][0] == ('test2:source', v1, ssldep)) Test2Loaded = Test3Loaded['test2'][1] assert (Test2Loaded['test1'][0] == ('test1:source', v1, rldep)) Test1Loaded = Test2Loaded['test1'][1] assert (Test1Loaded == {}) loadedTroves = loader.getLoadedTroves() assert (len(loadedTroves) == 3) assert (loadedTroves[0] == ('test1:source', v1, rldep)) assert (loadedTroves[1] == ('test2:source', v1, ssldep)) assert (loadedTroves[2] == ('test3:source', v1, nobsdep)) # Now reset and load again w/ overrides specified branch = versions.VersionFromString('/localhost@rpl:foo/') oldLoadedSpecs = loader.getLoadedSpecs() # move ILP and buildLabel over to another branch, and use overrides # to load exactly what we want anyway. cfg = copy.copy(self.cfg) cfg.installLabelPath = [versions.Label('localhost@rpl:foo')] cfg.buildLabel = versions.Label('localhost@rpl:foo') self.overrideBuildFlavor('!readline, !ssl') overrides = oldLoadedSpecs loader = self._testSubload(repos, "loadInstalled('test3')", cfg=cfg, overrides=overrides) assert (loadedTroves[0] == ('test1:source', v1, rldep)) assert (loadedTroves[1] == ('test2:source', v1, ssldep)) assert (loadedTroves[2] == ('test3:source', v1, nobsdep))
def testLoadedTrovesWithAutoLoad(self): self.logFilter.add() repos = self.openRepository() if 'x86_64' not in str(self.cfg.buildFlavor): raise testhelp.SkipTestException('Skip test on x86 arch') self.cfg.autoLoadRecipes.append('other') self.overrideBuildFlavor('is: x86 x86_64') header = ''' if Arch.x86: pass ''' self.addComponent( 'other:recipe=2.0[is:x86 x86_64]', [('simplesuper.recipe', simpleSuperRecipe.replace('1.0', '2.0'))]) self.addCollection('other=2.0[is:x86 x86_64]', [':recipe']) self.addTestPkg(1, version='1.0', header=header) self.addTestPkg(2, header='loadRecipe("test1")') use.track() rldep = deps.parseFlavor('readline') ssldep = deps.parseFlavor('ssl') nobsdep = deps.parseFlavor('~!bootstrap') emptydep = deps.Flavor() x64dep = deps.parseFlavor('is:x86_64') v1 = versions.VersionFromString('/localhost@rpl:linux/1.0-1') loader = self._testSubload(repos, "loadInstalled('test2')") FooLoaded = loader.getLoadedSpecs() assertEq = self.assertEqual assertEq(FooLoaded['test2'][0], ('test2:source', v1, emptydep)) Test2Loaded = FooLoaded['test2'][1] assertEq(Test2Loaded['test1'][0], ('test1:source', v1, x64dep)) Test1Loaded = Test2Loaded['test1'][1] assertEq(Test1Loaded, {}) loadedTroves = loader.getLoadedTroves() assertEq(len(loadedTroves), 2) assertEq(loadedTroves[0], ('test1:source', v1, x64dep)) assertEq(loadedTroves[1], ('test2:source', v1, emptydep)) # Now reset and load again w/ overrides specified branch = versions.VersionFromString('/localhost@rpl:foo/') oldLoadedSpecs = loader.getLoadedSpecs() # move ILP and buildLabel over to another branch, and use overrides # to load exactly what we want anyway. cfg = copy.copy(self.cfg) self.overrideBuildFlavor('!readline, !ssl') overrides = oldLoadedSpecs loader = self._testSubload(repos, "loadInstalled('test2')", cfg=cfg, overrides=overrides) assert (loadedTroves[0] == ('test1:source', v1, x64dep)) assert (loadedTroves[1] == ('test2:source', v1, emptydep))
def testLoadedTrovesWithAutoLoad(self): self.logFilter.add() repos = self.openRepository() if 'x86_64' not in str(self.cfg.buildFlavor): raise testhelp.SkipTestException('Skip test on x86 arch') self.cfg.autoLoadRecipes.append('other') self.overrideBuildFlavor('is: x86 x86_64') header = ''' if Arch.x86: pass ''' self.addComponent('other:recipe=2.0[is:x86 x86_64]', [('simplesuper.recipe', simpleSuperRecipe.replace('1.0', '2.0'))]) self.addCollection('other=2.0[is:x86 x86_64]', [':recipe']) self.addTestPkg(1, version='1.0', header=header) self.addTestPkg(2, header='loadRecipe("test1")') use.track() rldep = deps.parseFlavor('readline') ssldep = deps.parseFlavor('ssl') nobsdep = deps.parseFlavor('~!bootstrap') emptydep = deps.Flavor() x64dep = deps.parseFlavor('is:x86_64') v1 = versions.VersionFromString('/localhost@rpl:linux/1.0-1') loader = self._testSubload(repos, "loadInstalled('test2')") FooLoaded = loader.getLoadedSpecs() assertEq = self.assertEqual assertEq(FooLoaded['test2'][0], ('test2:source', v1, emptydep)) Test2Loaded = FooLoaded['test2'][1] assertEq(Test2Loaded['test1'][0], ('test1:source', v1, x64dep)) Test1Loaded = Test2Loaded['test1'][1] assertEq(Test1Loaded, {}) loadedTroves = loader.getLoadedTroves() assertEq(len(loadedTroves), 2) assertEq(loadedTroves[0], ('test1:source', v1, x64dep)) assertEq(loadedTroves[1], ('test2:source', v1, emptydep)) # Now reset and load again w/ overrides specified branch = versions.VersionFromString('/localhost@rpl:foo/') oldLoadedSpecs = loader.getLoadedSpecs() # move ILP and buildLabel over to another branch, and use overrides # to load exactly what we want anyway. cfg = copy.copy(self.cfg) self.overrideBuildFlavor('!readline, !ssl') overrides = oldLoadedSpecs loader = self._testSubload(repos, "loadInstalled('test2')", cfg = cfg, overrides = overrides) assert(loadedTroves[0] == ('test1:source', v1, x64dep)) assert(loadedTroves[1] == ('test2:source', v1, emptydep))
def testLoadedTroves(self): # we don't check the output of this test. self.logFilter.add() repos = self.openRepository() header = ''' if Use.%s: foo = '1.0-readline' else: foo = '1.0-noreadline' ''' self.addTestPkg(1, version='1.0', header=header % 'readline') self.addTestPkg(2, header='loadRecipe("test1")' + header % 'ssl') test3Recipe = self.addTestPkg(3, header='loadRecipe("test2")' + header % 'bootstrap') use.track() rldep = deps.parseFlavor('readline') ssldep = deps.parseFlavor('ssl') nobsdep = deps.parseFlavor('~!bootstrap') v1 = versions.VersionFromString('/localhost@rpl:linux/1.0-1') loader = self._testSubload(repos, "loadInstalled('test3')") FooLoaded = loader.getLoadedSpecs() assert(FooLoaded['test3'][0] == ('test3:source', v1, nobsdep)) Test3Loaded = FooLoaded['test3'][1] assert(Test3Loaded['test2'][0] == ('test2:source', v1, ssldep)) Test2Loaded = Test3Loaded['test2'][1] assert(Test2Loaded['test1'][0] == ('test1:source', v1, rldep)) Test1Loaded = Test2Loaded['test1'][1] assert(Test1Loaded == {}) loadedTroves = loader.getLoadedTroves() assert(len(loadedTroves) == 3) assert(loadedTroves[0] == ('test1:source', v1, rldep)) assert(loadedTroves[1] == ('test2:source', v1, ssldep)) assert(loadedTroves[2] == ('test3:source', v1, nobsdep)) # Now reset and load again w/ overrides specified branch = versions.VersionFromString('/localhost@rpl:foo/') oldLoadedSpecs = loader.getLoadedSpecs() # move ILP and buildLabel over to another branch, and use overrides # to load exactly what we want anyway. cfg = copy.copy(self.cfg) cfg.installLabelPath = [versions.Label('localhost@rpl:foo')] cfg.buildLabel = versions.Label('localhost@rpl:foo') self.overrideBuildFlavor('!readline, !ssl') overrides = oldLoadedSpecs loader = self._testSubload(repos, "loadInstalled('test3')", cfg = cfg, overrides = overrides) assert(loadedTroves[0] == ('test1:source', v1, rldep)) assert(loadedTroves[1] == ('test2:source', v1, ssldep)) assert(loadedTroves[2] == ('test3:source', v1, nobsdep))
def loadRecipeClass( repos, name, version, flavor, trv=None, ignoreInstalled=True, root=None, loadInstalledSource=None, overrides=None, buildLabel=None, cfg=None, ): if trv is None: trv = repos.getTrove(name, version, deps.parseFlavor(""), withFiles=True) if cfg is None: cfg = conarycfg.ConaryConfiguration(False) else: cfg = copy.deepcopy(cfg) cfg.initializeFlavors() if root: cfg.root = root branch = version.branch() label = version.branch().label() cfg.buildLabel = label cfg.buildFlavor = flavor name = name.split(":")[0] use.LocalFlags._clear() use.setBuildFlagsFromFlavor(name, flavor, error=False) use.resetUsed() use.track(True) loader = RecipeLoaderFromSourceTrove( trv, repos, cfg, name + ":source", branch, ignoreInstalled=ignoreInstalled, db=loadInstalledSource, overrides=overrides, buildFlavor=flavor, ) recipeClass = loader.getRecipe() recipeClass._trove = trv use.track(False) localFlags = flavorutil.getLocalFlags() usedFlags = use.getUsed() use.LocalFlags._clear() return loader, recipeClass, localFlags, usedFlags
def loadRecipeClass(repos, name, version, flavor, trv=None, ignoreInstalled=True, root=None, loadInstalledSource=None, overrides=None, buildLabel=None, cfg=None): if trv is None: trv = repos.getTrove(name, version, deps.parseFlavor(''), withFiles=True) if cfg is None: cfg = conarycfg.ConaryConfiguration(False) else: cfg = copy.deepcopy(cfg) cfg.initializeFlavors() if root: cfg.root = root branch = version.branch() label = version.branch().label() cfg.buildLabel = label cfg.buildFlavor = flavor name = name.split(':')[0] use.LocalFlags._clear() use.setBuildFlagsFromFlavor(name, flavor, error=False) use.resetUsed() use.track(True) loader = RecipeLoaderFromSourceTrove(trv, repos, cfg, name + ':source', branch, ignoreInstalled=ignoreInstalled, db=loadInstalledSource, overrides=overrides, buildFlavor=flavor) recipeClass = loader.getRecipe() recipeClass._trove = trv use.track(False) localFlags = flavorutil.getLocalFlags() usedFlags = use.getUsed() use.LocalFlags._clear() return loader, recipeClass, localFlags, usedFlags
def testTrack(self): Use = use.UseCollection() Use._addFlag('foo', value=True) Use._addFlag('bar', value=False) Use._addFlag('bam', value=False) assert(Use._getUsed() == []) Use._trackUsed(True) assert(bool(Use.foo)) assert(str(Use._getUsed()) == '[foo: True]') Use._trackUsed(False) bool(Use.bar) assert(str(Use._getUsed()) == '[foo: True]') Use._resetUsed() assert(Use._getUsed() == []) Use.foo._set(False) Use._trackUsed(True) assert(not bool(Use.foo)) Use._getUsed() assert(str(Use._getUsed()) == '[foo: False]') Use._trackUsed(False) use.setUsed([Use.bar]) Use._getUsed() assert(str(Use._getUsed()) == '[foo: False, bar: False]') Use._resetUsed() Use._trackUsed(True) Use.bar._set() assert(bool(Use.bar)) Use._getUsed() assert(str(Use._getUsed()) == '[bar: True]') Use._resetUsed() Use.bar._set() Use.foo._set(False) Use._trackUsed(True) assert(Use.bar | Use.foo) assert(set(x._name for x in Use._iterUsed()) == set(['bar', 'foo'])) Use._resetUsed() Use._trackUsed(True) assert(not Use.foo & Use.bar) assert(set(x._name for x in Use._iterUsed()) == set(['bar', 'foo'])) Use._resetUsed() Use._trackUsed(True) assert(not (Use.foo & Use.bar & Use.bam)) sorted(x._name for x in Use._iterUsed()) assert(set(x._name for x in Use._iterUsed()) == \ set(['bam', 'bar', 'foo'])) Use._resetUsed() Use._trackUsed(True) assert(Use.foo | Use.bar | Use.bam) assert(set(x._name for x in Use._iterUsed()) == \ set(['bam', 'bar', 'foo'])) Use._resetUsed() Use._trackUsed(True) assert(not (Use.foo == True)) assert([x._name for x in Use._iterUsed()] == ['foo']) Use._resetUsed() Use._trackUsed(True) assert(True != Use.foo) assert([x._name for x in Use._iterUsed()] == ['foo']) Arch = use.Arch use.resetUsed() use.track(True) assert(not bool(Arch.ppc.ppc64)) use.track(False) assert(use.getUsed() == [Arch.getCurrentArch()])
def loadRecipe(repos, name, version, flavor, trv, defaultFlavor=None, loadInstalledSource=None, installLabelPath=None, buildLabel=None, groupRecipeSource=None, cfg=None): name = name.split(':')[0] try: if defaultFlavor is not None: fullFlavor = deps.overrideFlavor(defaultFlavor, flavor) else: fullFlavor = flavor # set up necessary flavors and track used flags before # calling loadRecipe, since even loading the class # may check some flags that may never be checked inside # the recipe recipeObj, loader = getRecipeObj( repos, name, version, fullFlavor, trv, loadInstalledSource=loadInstalledSource, installLabelPath=installLabelPath, buildLabel=buildLabel, cfg=cfg) relevantFlavor = use.usedFlagsToFlavor(recipeObj.name) relevantFlavor = flavorutil.removeInstructionSetFlavor(relevantFlavor) # always add in the entire arch flavor. We need to ensure the # relevant flavor is unique per architecture, also, arch flavors # can affect the macros used. if defaultFlavor is not None: relevantFlavor.union(flavor) relevantFlavor.union(flavorutil.getArchFlags(fullFlavor)) relevantFlags = flavorutil.getFlavorUseFlags(relevantFlavor) flags = flavorutil.getFlavorUseFlags(fullFlavor) use.track(False) for flagSet in ('Use', ): # allow local flags not to be used -- they are set to their default if flagSet not in relevantFlags: continue for flag in relevantFlags[flagSet]: if flag not in flags[flagSet]: raise (RuntimeError, "Recipe %s uses Flavor %s but value not known" % (name, flag)) if 'Arch' in relevantFlags: for majarch in relevantFlags['Arch'].keys(): for subarch in relevantFlags['Arch'][majarch]: if not use.Arch[majarch][subarch]: #negative values for subarches are assumed continue if subarch not in flags['Arch'][majarch]: log.error("arch %s.%s used but not specified" % (majarch, subarch)) raise RuntimeError, ( "arch %s.%s used but not specified" % (majarch, subarch)) use.resetUsed() except: log.error('Error Loading Recipe (%s, %s, %s):\n%s' % (name, version, fullFlavor, ''.join(traceback.format_exc()))) raise return loader, recipeObj, relevantFlavor
def getRecipeObj(repos, name, version, flavor, trv, loadInstalledSource=None, installLabelPath=None, loadRecipeSpecs=None, buildLabel=None, groupRecipeSource=None, cfg=None): if cfg: cfg = copy.deepcopy(cfg) else: cfg = conarycfg.ConaryConfiguration(False) cfg.initializeFlavors() branch = version.branch() if not buildLabel: buildLabel = version.branch().label() if not installLabelPath: cfg.installLabelPath = [buildLabel] else: cfg.installLabelPath = installLabelPath cfg.buildFlavor = flavor cfg.defaultBasePackages = [] name = name.split(':')[0] use.LocalFlags._clear() assert (flavorutil.getArch(flavor)) use.setBuildFlagsFromFlavor(name, flavor, error=False) use.resetUsed() use.track(True) ignoreInstalled = not loadInstalledSource macros = { 'buildlabel': buildLabel.asString(), 'buildbranch': version.branch().asString() } cfg.lookaside = tempfile.mkdtemp() try: loader = RecipeLoaderFromSourceTrove(trv, repos, cfg, name + ':source', branch, ignoreInstalled=ignoreInstalled, db=loadInstalledSource, buildFlavor=flavor) recipeClass = loader.getRecipe() recipeClass._trove = trv if recipe.isGroupRecipe(recipeClass): recipeObj = recipeClass(repos, cfg, buildLabel, flavor, None, extraMacros=macros) recipeObj.sourceVersion = version recipeObj.loadPolicy() recipeObj.setup() elif (recipe.isPackageRecipe(recipeClass) or recipe.isFactoryRecipe(recipeClass) or recipe.isCapsuleRecipe(recipeClass)): if recipe.isFactoryRecipe(recipeClass): #This requires a specific capability in conary compat.ConaryVersion().requireFactoryRecipeGeneration() #Load the FactoryRecipe factoryClass = recipeClass loaded = cook.loadFactoryRecipe(factoryClass, cfg, repos, flavor) recipeClass = loaded.getRecipe() lcache = lookaside.RepositoryCache(repos) recipeObj = recipeClass(cfg, lcache, [], macros, lightInstance=True) recipeObj.sourceVersion = version recipeObj.populateLcache() if not recipeObj.needsCrossFlags(): recipeObj.crossRequires = [] recipeObj.loadPolicy() recipeObj.setup() elif recipe.isInfoRecipe(recipeClass): recipeObj = recipeClass(cfg, None, None, macros) recipeObj.sourceVersion = version recipeObj.setup() elif recipe.isRedirectRecipe(recipeClass): binaryBranch = version.getBinaryVersion().branch() recipeObj = recipeClass(repos, cfg, binaryBranch, flavor) recipeObj.sourceVersion = version recipeObj.setup() elif recipe.isFileSetRecipe(recipeClass): recipeObj = recipeClass(repos, cfg, buildLabel, flavor, extraMacros=macros) recipeObj.sourceVersion = version recipeObj.setup() else: raise RuntimeError, 'Unknown class type %s for recipe %s' % ( recipeClass, name) finally: util.rmtree(cfg.lookaside) return recipeObj, loader
def getRecipeObj( repos, name, version, flavor, trv, loadInstalledSource=None, installLabelPath=None, loadRecipeSpecs=None, buildLabel=None, groupRecipeSource=None, cfg=None, ): if cfg: cfg = copy.deepcopy(cfg) else: cfg = conarycfg.ConaryConfiguration(False) cfg.initializeFlavors() branch = version.branch() if not buildLabel: buildLabel = version.branch().label() if not installLabelPath: cfg.installLabelPath = [buildLabel] else: cfg.installLabelPath = installLabelPath cfg.buildFlavor = flavor cfg.defaultBasePackages = [] name = name.split(":")[0] use.LocalFlags._clear() assert flavorutil.getArch(flavor) use.setBuildFlagsFromFlavor(name, flavor, error=False) use.resetUsed() use.track(True) ignoreInstalled = not loadInstalledSource macros = {"buildlabel": buildLabel.asString(), "buildbranch": version.branch().asString()} cfg.lookaside = tempfile.mkdtemp() try: loader = RecipeLoaderFromSourceTrove( trv, repos, cfg, name + ":source", branch, ignoreInstalled=ignoreInstalled, db=loadInstalledSource, buildFlavor=flavor, ) recipeClass = loader.getRecipe() recipeClass._trove = trv if recipe.isGroupRecipe(recipeClass): recipeObj = recipeClass(repos, cfg, buildLabel, flavor, None, extraMacros=macros) recipeObj.sourceVersion = version recipeObj.loadPolicy() recipeObj.setup() elif ( recipe.isPackageRecipe(recipeClass) or recipe.isFactoryRecipe(recipeClass) or recipe.isCapsuleRecipe(recipeClass) ): if recipe.isFactoryRecipe(recipeClass): # This requires a specific capability in conary compat.ConaryVersion().requireFactoryRecipeGeneration() # Load the FactoryRecipe factoryClass = recipeClass loaded = cook.loadFactoryRecipe(factoryClass, cfg, repos, flavor) recipeClass = loaded.getRecipe() lcache = lookaside.RepositoryCache(repos) recipeObj = recipeClass(cfg, lcache, [], macros, lightInstance=True) recipeObj.sourceVersion = version recipeObj.populateLcache() if not recipeObj.needsCrossFlags(): recipeObj.crossRequires = [] recipeObj.loadPolicy() recipeObj.setup() elif recipe.isInfoRecipe(recipeClass): recipeObj = recipeClass(cfg, None, None, macros) recipeObj.sourceVersion = version recipeObj.setup() elif recipe.isRedirectRecipe(recipeClass): binaryBranch = version.getBinaryVersion().branch() recipeObj = recipeClass(repos, cfg, binaryBranch, flavor) recipeObj.sourceVersion = version recipeObj.setup() elif recipe.isFileSetRecipe(recipeClass): recipeObj = recipeClass(repos, cfg, buildLabel, flavor, extraMacros=macros) recipeObj.sourceVersion = version recipeObj.setup() else: raise RuntimeError, "Unknown class type %s for recipe %s" % (recipeClass, name) finally: util.rmtree(cfg.lookaside) return recipeObj, loader
def testTrack(self): Use = use.UseCollection() Use._addFlag('foo', value=True) Use._addFlag('bar', value=False) Use._addFlag('bam', value=False) assert (Use._getUsed() == []) Use._trackUsed(True) assert (bool(Use.foo)) assert (str(Use._getUsed()) == '[foo: True]') Use._trackUsed(False) bool(Use.bar) assert (str(Use._getUsed()) == '[foo: True]') Use._resetUsed() assert (Use._getUsed() == []) Use.foo._set(False) Use._trackUsed(True) assert (not bool(Use.foo)) Use._getUsed() assert (str(Use._getUsed()) == '[foo: False]') Use._trackUsed(False) use.setUsed([Use.bar]) Use._getUsed() assert (str(Use._getUsed()) == '[foo: False, bar: False]') Use._resetUsed() Use._trackUsed(True) Use.bar._set() assert (bool(Use.bar)) Use._getUsed() assert (str(Use._getUsed()) == '[bar: True]') Use._resetUsed() Use.bar._set() Use.foo._set(False) Use._trackUsed(True) assert (Use.bar | Use.foo) assert (set(x._name for x in Use._iterUsed()) == set(['bar', 'foo'])) Use._resetUsed() Use._trackUsed(True) assert (not Use.foo & Use.bar) assert (set(x._name for x in Use._iterUsed()) == set(['bar', 'foo'])) Use._resetUsed() Use._trackUsed(True) assert (not (Use.foo & Use.bar & Use.bam)) sorted(x._name for x in Use._iterUsed()) assert(set(x._name for x in Use._iterUsed()) == \ set(['bam', 'bar', 'foo'])) Use._resetUsed() Use._trackUsed(True) assert (Use.foo | Use.bar | Use.bam) assert(set(x._name for x in Use._iterUsed()) == \ set(['bam', 'bar', 'foo'])) Use._resetUsed() Use._trackUsed(True) assert (not (Use.foo == True)) assert ([x._name for x in Use._iterUsed()] == ['foo']) Use._resetUsed() Use._trackUsed(True) assert (True != Use.foo) assert ([x._name for x in Use._iterUsed()] == ['foo']) Arch = use.Arch use.resetUsed() use.track(True) assert (not bool(Arch.ppc.ppc64)) use.track(False) assert (use.getUsed() == [Arch.getCurrentArch()])