~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/config.py

  • Committer: Vincent Ladeuil
  • Date: 2011-12-21 14:25:26 UTC
  • mto: This revision was merged to the branch mainline in revision 6397.
  • Revision ID: v.ladeuil+lp@free.fr-20111221142526-pnwau0xnalimujts
Provides MemoryStack to simplify configuration setup in tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
3495
3495
        return []
3496
3496
 
3497
3497
 
 
3498
class MemoryStack(Stack):
 
3499
    """A configuration stack defined from a string.
 
3500
 
 
3501
    This is mainly intended for tests and requires no disk resources.
 
3502
    """
 
3503
 
 
3504
    def __init__(self, content=None):
 
3505
        """Create an in-memory stack from a given content.
 
3506
 
 
3507
        It uses a single store based on configobj and support reading and
 
3508
        writing options.
 
3509
 
 
3510
        :param content: The initial content of the store. If None, the store is
 
3511
            not loaded and ``_load_from_string`` can and should be used if
 
3512
            needed.
 
3513
        """
 
3514
        store = IniFileStore()
 
3515
        if content is not None:
 
3516
            store._load_from_string(content)
 
3517
        super(MemoryStack, self).__init__(
 
3518
            [store.get_sections], store)
 
3519
 
 
3520
 
3498
3521
class _CompatibleStack(Stack):
3499
3522
    """Place holder for compatibility with previous design.
3500
3523