~hazmat/pyjuju/proposed-support

« back to all changes in this revision

Viewing changes to juju/lib/testing.py

merge refactor-machine-agent [r=bcsaller,hazmat][f=925211]

Refactors machine agent such that unit agent deployment is separated
into a new class (UnitDeployer).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import itertools
1
2
import logging
2
3
import os
3
4
import StringIO
118
119
    def assertInstance(self, instance, type):
119
120
        self.assertTrue(isinstance(instance, type))
120
121
 
 
122
    def assertLogLines(self, observed, expected):
 
123
        """Asserts that the lines of `expected` exist in order in the log."""
 
124
        logged = observed.split("\n")
 
125
        it = iter(expected)
 
126
        for line in logged:
 
127
            it, peekat = itertools.tee(it)
 
128
            peeked = next(peekat)
 
129
            if peeked in line:
 
130
                next(it)  # then consume this line and move on
 
131
 
 
132
        self.assertFalse(
 
133
            expected,
 
134
            "Did not see all expected lines in log, in order: %s, %s" % (
 
135
                observed, expected))
 
136
 
121
137
    def sleep(self, delay):
122
138
        """Non-blocking sleep."""
123
139
        deferred = Deferred()