test_build_doubles.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:acceptable 作者: canonical-ols 项目源码 文件源码
def test_logs_on_schema_extraction(self):
        workdir = self.useFixture(fixtures.TempDir())
        fake_logger = self.useFixture(fixtures.FakeLogger())

        good_path = os.path.join(workdir.path, 'my.py')
        with open(good_path, 'w') as f:
            f.write(dedent(
                """
                service = AcceptableService('vendor')

                root_api = service.api('/', 'root')

                @root_api.view(introduced_at='1.0')
                def my_view():
                    pass
                """))
        [schema] = _build_doubles.extract_schemas_from_file(good_path)

        self.assertEqual('root', schema.view_name)
        self.assertEqual('1.0', schema.version)
        self.assertEqual(['GET'], schema.methods)
        self.assertEqual(None, schema.input_schema)
        self.assertEqual(None, schema.output_schema)

        self.assertThat(
            fake_logger.output,
            Contains('Extracting schemas from %s' % good_path))
        self.assertThat(
            fake_logger.output,
            Contains('Extracted 1 schema'))


# To support testing, we need a version of ArgumentParser that doesn't call
# sys.exit on error, but rather throws an exception, so we can catch that in
# our tests:
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号