test_cli.py 文件源码

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

项目:env-diff 作者: jacebrowning 项目源码 文件源码
def describe_do_run():

    @pytest.yield_fixture
    def config(tmpdir):
        cwd = os.getcwd()
        tmpdir.chdir()

        with Path(".env").open('w') as f:
            f.write("FOO=1")

        with Path("app.py").open('w') as f:
            f.write("os.getenv('FOO', 2)")

        yield Config.new(
            sourcefiles=[
                SourceFile(".env"),
                SourceFile("app.py"),
            ],
            environments=[
                Environment("test", command="echo FOO=3"),
            ],
        )

        os.chdir(cwd)

    def it_returns_table_data(runner, config):
        print(config.sourcefiles)
        data = do_run(config)

        expect(list(data)) == [
            ['Variable', 'File: .env', 'File: app.py', 'Environment: test'],
            ['FOO', 'FOO=1', "os.getenv('FOO', 2)", '3'],
        ]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号