def test_get_fixtures_with_fixtures(tmpdir): file = tmpdir.join("myfixtures.py") file.write(build_fixture_module("fixt")) project = Project( SimpleProjectConfiguration(tmpdir.strpath, tmpdir.strpath), tmpdir.strpath) fixtures = project.get_fixtures() assert len(fixtures) == 1 and fixtures[0].name == "fixt"
def test_with_custom_cli_args(tmpdir): class MyProject(SimpleProjectConfiguration, HasCustomCliArgs): def add_custom_cli_args(self, cli_parser): cli_parser.add_argument("foobar") project = Project(MyProject(tmpdir.strpath), tmpdir.strpath) cli_parser = argparse.ArgumentParser() project.add_custom_args_to_run_cli(cli_parser) assert "foobar" in [a.dest for a in cli_parser._actions]
def test_with_post_run_hook(tmpdir): marker = [] class MyProject(SimpleProjectConfiguration, HasPostRunHook): def post_run(self, cli_args, report_dir): marker.append(1) project = Project(MyProject(tmpdir.strpath), tmpdir.strpath) project.run_post_session_hook(object(), tmpdir.strpath) assert len(marker) == 1
def test_get_suites_without_metadatapolicy_check(tmpdir): @lcc.suite("My Suite") class mysuite: @lcc.test("My Test") @lcc.tags("mytag") def test(self): pass class MyProject(SimpleProjectConfiguration, HasMetadataPolicy): def get_metadata_policy(self): mp = MetadataPolicy() mp.disallow_unknown_tags() return mp def get_suites(self): return [load_suite_from_class(mysuite)] project = Project(MyProject(tmpdir.strpath), tmpdir.strpath) project.get_suites(check_metadata_policy=False)
def test_pre_run(tmpdir): marker = [] class ProjectConfig(DummyProjectConfiguration, HasPreRunHook): def pre_run(self, cli_args, report_dir): marker.append(cli_args.command) project = Project(ProjectConfig([DUMMY_SUITE]), tmpdir.strpath) run_project(project, build_cli_args(["run"])) assert marker == ["run"]
def make_test_project(project_dir): return Project(SimpleProjectConfiguration(project_dir.strpath), project_dir.strpath)
import os.path from lemoncheesecake.project import Project project_dir = os.path.dirname(__file__) project = Project(project_dir)
def build_project(suites, tmpdir): return Project(DummyProjectConfiguration(suites), tmpdir.strpath)