Пример #1
0
 def test_internalerror(self, testdir, linecomp):
     modcol = testdir.getmodulecol("def test_one(): pass")
     rep = TerminalReporter(modcol.config, file=linecomp.stringio)
     excinfo = py.test.raises(ValueError, "raise ValueError('hello')")
     rep.pytest_internalerror(excinfo.getrepr())
     linecomp.assert_contains_lines([
         "INTERNALERROR> *raise ValueError*"
     ])
Пример #2
0
 def test_writeline(self, testdir, linecomp):
     modcol = testdir.getmodulecol("def test_one(): pass")
     stringio = py.std.cStringIO.StringIO()
     rep = TerminalReporter(modcol.config, file=linecomp.stringio)
     rep.write_fspath_result(py.path.local("xy.py"), '.')
     rep.write_line("hello world")
     lines = linecomp.stringio.getvalue().split('\n')
     assert not lines[0]
     assert lines[1].endswith("xy.py .")
     assert lines[2] == "hello world"
Пример #3
0
 def test_looponfailreport(self, testdir, linecomp):
     modcol = testdir.getmodulecol("""
         def test_fail():
             assert 0
         def test_fail2():
             raise ValueError()
     """)
     rep = TerminalReporter(modcol.config, file=linecomp.stringio)
     reports = [basic_run_report(x) for x in modcol.collect()]
     rep.pytest_looponfailinfo(reports, [modcol.config.topdir])
     linecomp.assert_contains_lines([
         "*test_looponfailreport.py:2: assert 0",
         "*test_looponfailreport.py:4: ValueError*",
         "*waiting*", 
         "*%s*" % (modcol.config.topdir),
     ])
Пример #4
0
    def test_gwmanage_events(self, testdir, linecomp):
        modcol = testdir.getmodulecol("""
            def test_one():
                pass
        """, configargs=("-v",))

        rep = TerminalReporter(modcol.config, file=linecomp.stringio)
        class gw1:
            id = "X1"
            spec = py.execnet.XSpec("popen")
        class gw2:
            id = "X2"
            spec = py.execnet.XSpec("popen")
        class rinfo:
            version_info = (2, 5, 1, 'final', 0)
            executable = "hello"
            platform = "xyz"
            cwd = "qwe"
        
        rep.pyexecnet_gwmanage_newgateway(gw1, rinfo)
        linecomp.assert_contains_lines([
            "X1*popen*xyz*2.5*"
        ])

        rep.pyexecnet_gwmanage_rsyncstart(source="hello", gateways=[gw1, gw2])
        linecomp.assert_contains_lines([
            "rsyncstart: hello -> X1, X2"
        ])
        rep.pyexecnet_gwmanage_rsyncfinish(source="hello", gateways=[gw1, gw2])
        linecomp.assert_contains_lines([
            "rsyncfinish: hello -> X1, X2"
        ])