Пример #1
0
def test_multitest_drivers(runpath):
    """TODO."""
    for idx, opts in enumerate((
            dict(name="Mtest", suites=[MySuite()], runpath=runpath),
            dict(name="Mtest", suites=[MySuite()]),
    )):
        server = TCPServer(name="server")
        client = TCPClient(
            name="client",
            host=context(server.cfg.name, "{{host}}"),
            port=context(server.cfg.name, "{{port}}"),
        )
        opts.update(
            environment=[server, client],
            initial_context={"test_key": "test_value"},
            stdout_style=defaults.STDOUT_STYLE,
            test_filter=Filter(),
            test_sorter=NoopSorter(),
        )

        mtest = MultiTest(**opts)
        assert server.status.tag == ResourceStatus.NONE
        assert client.status.tag == ResourceStatus.NONE
        res = mtest.run()
        assert res.run is True
        assert res.report.passed
        if idx == 0:
            assert mtest.runpath == runpath
        else:
            assert mtest.runpath == default_runpath(mtest)
        assert server.runpath == os.path.join(mtest.runpath, server.uid())
        assert client.runpath == os.path.join(mtest.runpath, client.uid())
        assert server.status.tag == ResourceStatus.STOPPED
        assert client.status.tag == ResourceStatus.STOPPED
Пример #2
0
    @testcase
    def test_b(self, env, result):
        pass

    @testcase
    def test_a(self, env, result):
        pass


# This is the sorter that's used by default:
# Test cases are run in their original declaration order.
# Test suites are run in the order they are added to a multitest.
# Multitests (instances) are run in the order they are added to the plan.

noop_sorter = NoopSorter()


# You can shuffle your test runs by using the built-in ShuffleSorter.
# This is advised as a good practice in case you are running testcases in
# parallel and they have race conditions.

# Just shuffle the testcases, keep original ordering of suites.
testcase_shuffler_a = ShuffleSorter('testcases')
testcase_shuffler_b = ShuffleSorter(SortType.TEST_CASES)


# Shuffle the suites only, using seed value of 15
suite_shuffler_a = ShuffleSorter(shuffle_type='suites', seed=15)
suite_shuffler_b = ShuffleSorter(shuffle_type=SortType.SUITES, seed=15)