Ejemplo n.º 1
0
 def test_empty_error(self):
     self.setupStep(
         subunit.SubunitShellCommand(command='test', failureOnNoTests=True))
     self.expectCommands(ExpectShell(workdir='wkdir', command="test") + 0)
     self.expectOutcome(result=FAILURE,
                        state_string="shell no tests run (failure)")
     return self.runStep()
Ejemplo n.º 2
0
    def test_multiple_errors(self):
        stream = io.BytesIO()
        client = TestProtocolClient(stream)
        test1 = FakeTest(id='test1')
        test2 = FakeTest(id='test2')
        client.startTest(test1)
        client.addError(test1, create_error('error1'))
        client.stopTest(test1)
        client.startTest(test2)
        client.addError(test2, create_error('error2'))
        client.stopTest(test2)

        self.setup_step(subunit.SubunitShellCommand(command='test'))
        self.expect_commands(
            ExpectShell(workdir='wkdir',
                        command="test").stdout(stream.getvalue()).exit(0))

        self.expect_outcome(
            result=FAILURE,
            state_string="shell Total 2 test(s) 2 errors (failure)")
        self.expect_log_file('problems', re.compile(r'''test1
testtools.testresult.real._StringException:.*ValueError: invalid literal for int\(\) with base 10: '_error1'

test2
testtools.testresult.real._StringException:.*ValueError: invalid literal for int\(\) with base 10: '_error2'
.*''', re.MULTILINE | re.DOTALL))  # noqa pylint: disable=line-too-long
        return self.run_step()
Ejemplo n.º 3
0
 def test_empty(self):
     self.setupStep(subunit.SubunitShellCommand(command='test'))
     self.expectCommands(
         ExpectShell(workdir='wkdir', usePTY='slave-config', command="test")
         + 0)
     self.expectOutcome(result=SUCCESS, state_string="shell no tests run")
     return self.runStep()
Ejemplo n.º 4
0
    def test_warnings(self):
        stream = io.BytesIO()
        client = TestProtocolClient(stream)
        test1 = FakeTest(id='test1')
        test2 = FakeTest(id='test2')
        client.startTest(test1)
        client.stopTest(test1)
        client.addError(test2, create_error('error2'))
        client.stopTest(test2)

        self.setupStep(subunit.SubunitShellCommand(command='test'))
        self.expectCommands(
            ExpectShell(workdir='wkdir', command="test") +
            Expect.log('stdio', stdout=stream.getvalue()) + 0)

        self.expectOutcome(
            result=SUCCESS,  # N.B. not WARNINGS
            state_string="shell 1 test passed")
        # note that the warnings list is ignored..
        self.expectLogfile(
            'warnings', '''\
error: test2 [
Traceback (most recent call last):
ValueError: invalid literal for int() with base 10: '_error2'
]
''')
        return self.runStep()
Ejemplo n.º 5
0
    def test_multiple_errors(self):
        stream = io.BytesIO()
        client = TestProtocolClient(stream)
        test1 = FakeTest(id='test1')
        test2 = FakeTest(id='test2')
        client.startTest(test1)
        client.addError(test1, create_error('error1'))
        client.stopTest(test1)
        client.startTest(test2)
        client.addError(test2, create_error('error2'))
        client.stopTest(test2)

        self.setupStep(subunit.SubunitShellCommand(command='test'))
        self.expectCommands(
            ExpectShell(workdir='wkdir', command="test") +
            Expect.log('stdio', stdout=stream.getvalue()) + 0)

        self.expectOutcome(
            result=FAILURE,
            state_string="shell Total 2 test(s) 2 errors (failure)")
        self.expectLogfile(
            'problems', '''\
test1
testtools.testresult.real._StringException: Traceback (most recent call last):
ValueError: invalid literal for int() with base 10: '_error1'

test2
testtools.testresult.real._StringException: Traceback (most recent call last):
ValueError: invalid literal for int() with base 10: '_error2'

''')
        return self.runStep()
Ejemplo n.º 6
0
 def test_empty_error(self):
     self.setupStep(
         subunit.SubunitShellCommand(command='test', failureOnNoTests=True))
     self.expectCommands(
         ExpectShell(workdir='wkdir', usePTY='slave-config', command="test")
         + 0)
     self.expectOutcome(result=FAILURE,
                        status_text=["shell", "no tests", "run"])
     return self.runStep()
Ejemplo n.º 7
0
 def test_warnings(self):
     self.setupStep(subunit.SubunitShellCommand(command='test'))
     self.expectCommands(ExpectShell(workdir='wkdir', command="test") + 0)
     self.logobserver.warnings.append('not quite up to snuff (list)')
     self.logobserver.warningio.write('not quite up to snuff (io)\n')
     self.logobserver.testsRun = 3
     self.expectOutcome(
         result=SUCCESS,  # N.B. not WARNINGS
         state_string="shell 3 tests passed")
     # note that the warnings list is ignored..
     self.expectLogfile('warnings', 'not quite up to snuff (io)\n')
     return self.runStep()
Ejemplo n.º 8
0
    def test_success(self):
        stream = io.BytesIO()
        client = TestProtocolClient(stream)
        test = FakeTest(id='test1')
        client.startTest(test)
        client.stopTest(test)

        self.setup_step(subunit.SubunitShellCommand(command='test'))
        self.expect_commands(
            ExpectShell(workdir='wkdir',
                        command="test").stdout(stream.getvalue()).exit(0))

        self.expect_outcome(result=SUCCESS, state_string="shell 1 test passed")
        return self.run_step()
Ejemplo n.º 9
0
    def test_error(self):
        stream = io.BytesIO()
        client = TestProtocolClient(stream)
        test = FakeTest(id='test1')
        client.startTest(test)
        client.addError(test, create_error('error1'))
        client.stopTest(test)

        self.setupStep(subunit.SubunitShellCommand(command='test'))
        self.expectCommands(
            ExpectShell(workdir='wkdir', command="test") +
            Expect.log('stdio', stdout=stream.getvalue()) + 0)

        self.expectOutcome(
            result=FAILURE,
            state_string="shell Total 1 test(s) 1 error (failure)")
        self.expectLogfile('problems', re.compile(r'''test1
testtools.testresult.real._StringException:.*ValueError: invalid literal for int\(\) with base 10: '_error1'
.*''', re.MULTILINE | re.DOTALL))  # noqa pylint: disable=line-too-long
        return self.runStep()
Ejemplo n.º 10
0
    def test_warnings(self):
        stream = io.BytesIO()
        client = TestProtocolClient(stream)
        test1 = FakeTest(id='test1')
        test2 = FakeTest(id='test2')
        client.startTest(test1)
        client.stopTest(test1)
        client.addError(test2, create_error('error2'))
        client.stopTest(test2)

        self.setup_step(subunit.SubunitShellCommand(command='test'))
        self.expect_commands(
            ExpectShell(workdir='wkdir',
                        command="test").stdout(stream.getvalue()).exit(0))

        self.expect_outcome(
            result=SUCCESS,  # N.B. not WARNINGS
            state_string="shell 1 test passed")
        # note that the warnings list is ignored..
        self.expect_log_file('warnings', re.compile(r'''error: test2 \[.*
ValueError: invalid literal for int\(\) with base 10: '_error2'
\]
''', re.MULTILINE | re.DOTALL))  # noqa pylint: disable=line-too-long
        return self.run_step()
Ejemplo n.º 11
0
 def test_empty(self):
     self.setup_step(subunit.SubunitShellCommand(command='test'))
     self.expect_commands(
         ExpectShell(workdir='wkdir', command="test").exit(0))
     self.expect_outcome(result=SUCCESS, state_string="shell no tests run")
     return self.run_step()