def test_build_package(self):
def run_build(build_fn=None, checks_fn=None, expect_error=False):
build_fn = os.path.join(os.path.dirname(__file__), build_fn) if build_fn else None
checks_fn = os.path.join(os.path.dirname(__file__), checks_fn) if checks_fn else None
if expect_error:
with assertRaisesRegex(self, IOError, 'doesnt_exist.yml'):
build.build_package('foox', 'barx', build_fn, checks_fn, dry_run=True)
else:
build.build_package('foox', 'barx', build_fn, checks_fn, dry_run=True)
run_build("build_simple_checks.yml", "checks_simple.yml")
run_build("doesnt_exist.yml", "checks_simple.yml", True)
run_build("build_simple_checks.yml", "doesnt_exist.yml", True)
run_build("build_simple_checks.yml", None)
# bad yaml files
with assertRaisesRegex(self, yaml.parser.ParserError, 'expected'):
run_build("build_simple_checks.yml", "test_checks.py")
with assertRaisesRegex(self, yaml.parser.ParserError, 'expected'):
run_build("test_checks.py", None)
评论列表
文章目录