Exemple #1
0
def test_addmarker_order():
    node = Node("Test", config=mock.Mock(), session=mock.Mock(), nodeid="Test")
    node.add_marker("a")
    node.add_marker("b")
    node.add_marker("c", append=False)
    extracted = [x.name for x in node.iter_markers()]
    assert extracted == ["c", "a", "b"]
    def test_flow_maxdetail(self):
        tmp = tempfile.NamedTemporaryFile()
        tmp.close()
        config = ctype(otype(tmp.name, 3), PytestPluginManager())
        plugin = ApiritifPytestPlugin(config)
        for _ in plugin.pytest_runtest_setup(None):
            pass

        with apiritif.transaction("tran") as tran:
            tran.set_request(bytes("test", 'utf8'))

        node = Node("test", nodeid="tst", config=config, session="some")
        for _ in plugin.pytest_runtest_teardown(node):
            pass

        plugin.pytest_sessionfinish(None)

        with open(tmp.name) as fp:
            data = json.load(fp)

        self.assertNotEqual({}, data)
    def test_flow_maxdetail(self):
        tmp = tempfile.NamedTemporaryFile()
        tmp.close()
        config = ctype(otype(tmp.name, 4), PytestPluginManager())
        plugin = ApiritifPytestPlugin(config)
        for _ in plugin.pytest_runtest_setup(None):
            pass

        with apiritif.transaction("tran") as tran:
            tran.set_request(bytes("test", 'utf8'))

        http.post('http://httpbin.org/post', data=bytes([0xa0, 1, 2, 3]),
                  headers={'Content-Type': 'application/octet-stream'})

        node = Node("test", nodeid="tst", config=config, session="some")
        for _ in plugin.pytest_runtest_teardown(node):
            pass

        plugin.pytest_sessionfinish(None)

        with open(tmp.name) as fp:
            data = json.load(fp)

        self.assertNotEqual({}, data)
Exemple #4
0
def test_generic_path(testdir):
    from _pytest.main import Session
    config = testdir.parseconfig()
    session = Session(config)
    p1 = Node('a', config=config, session=session)
    # assert p1.fspath is None
    p2 = Node('B', parent=p1)
    p3 = Node('()', parent=p2)
    item = Item('c', parent=p3)

    res = generic_path(item)
    assert res == 'a.B().c'

    p0 = FSCollector('proj/test', config=config, session=session)
    p1 = FSCollector('proj/test/a', parent=p0)
    p2 = Node('B', parent=p1)
    p3 = Node('()', parent=p2)
    p4 = Node('c', parent=p3)
    item = Item('[1]', parent=p4)

    res = generic_path(item)
    assert res == 'test/a:B().c[1]'
def test_generic_path(testdir):
    from _pytest.main import Session

    config = testdir.parseconfig()
    session = Session(config)
    p1 = Node("a", config=config, session=session, nodeid="a")
    # assert p1.fspath is None
    p2 = Node("B", parent=p1)
    p3 = Node("()", parent=p2)
    item = Item("c", parent=p3)

    res = generic_path(item)
    assert res == "a.B().c"

    p0 = FSCollector("proj/test", config=config, session=session)
    p1 = FSCollector("proj/test/a", parent=p0)
    p2 = Node("B", parent=p1)
    p3 = Node("()", parent=p2)
    p4 = Node("c", parent=p3)
    item = Item("[1]", parent=p4)

    res = generic_path(item)
    assert res == "test/a:B().c[1]"
Exemple #6
0
def test_addmarker_getmarker():
    node = Node("Test", config=mock.Mock(), session=mock.Mock(), nodeid="Test")
    node.add_marker(pytest.mark.a(1))
    node.add_marker("b")
    node.get_marker("a").combined
    node.get_marker("b").combined