class ConfigTestCase(TestCase):
+ def testClone(self):
+ """
+ Test the clone via constructor.
+ """
+
+ ebuilds = {
+ "dev-libs/A-1": { },
+ }
+
+ playground = ResolverPlayground(ebuilds=ebuilds)
+ try:
+ settings = config(clone=playground.settings)
+ result = playground.run(["=dev-libs/A-1"])
+ pkg, existing_node = result.depgraph._select_package(
+ playground.root, "=dev-libs/A-1")
+ settings.setcpv(pkg)
+
+ # clone after setcpv tests deepcopy of LazyItemsDict
+ settings2 = config(clone=settings)
+ finally:
+ playground.cleanup()
+
def testFeaturesMutation(self):
"""
Test whether mutation of config.features updates the FEATURES
k_copy = deepcopy(k, memo)
if k in self.lazy_items:
lazy_item = self.lazy_items[k]
- try:
- result.lazy_items[k_copy] = deepcopy(lazy_item, memo)
- except TypeError:
- if not lazy_item.singleton:
- raise
- UserDict.__setitem__(result,
- k_copy, deepcopy(self[k], memo))
- else:
- UserDict.__setitem__(result, k_copy, None)
+ if not lazy_item.singleton:
+ raise TypeError("LazyItemsDict deepcopy is " + \
+ "unsafe with lazy items that " + \
+ "are not singletons: %s" % (lazy_item,))
+ UserDict.__setitem__(result,
+ k_copy, deepcopy(self[k], memo))
else:
UserDict.__setitem__(result, k_copy, deepcopy(self[k], memo))
return result