示例#1
0
    def test_simple_rule_one_input(self):
        stream = StringIO("rule a:\n" f'{TAB * 1}input: "foo.txt"')
        smk = Snakefile(stream)
        formatter = Formatter(smk)

        actual = formatter.get_formatted()
        expected = "rule a:\n" f"{TAB * 1}input:\n" f'{TAB * 2}"foo.txt",\n'

        assert actual == expected
示例#2
0
    def test_lambda_function_with_multiple_args(self):
        stream = StringIO(
            f"rule a:\n"
            f'{TAB * 1}input: "foo.txt" \n'
            f"{TAB * 1}resources:"
            f"{TAB * 2}mem_mb = lambda wildcards, attempt: attempt * 1000")
        smk = Snakefile(stream)
        formatter = Formatter(smk)

        actual = formatter.get_formatted()
        expected = (
            f"rule a:\n"
            f"{TAB * 1}input:\n"
            f'{TAB * 2}"foo.txt",\n'
            f"{TAB * 1}resources:\n"
            f"{TAB * 2}mem_mb=lambda wildcards, attempt: attempt * 1000,\n")

        assert actual == expected
示例#3
0
    def test_expand_as_param(self):
        stream = StringIO("rule a:\n"
                          f"{TAB * 1}input: \n"
                          f"{TAB * 2}"
                          'expand("{f}/{p}", f = [1, 2], p = ["1", "2"])\n'
                          f'{TAB * 1}output:"foo.txt","bar.txt"\n')

        smk = Snakefile(stream)
        formatter = Formatter(smk)
        actual = formatter.get_formatted()

        expected = ("rule a:\n"
                    f"{TAB * 1}input:\n"
                    f"{TAB * 2}"
                    'expand("{f}/{p}", f=[1, 2], p=["1", "2"]),\n'
                    f"{TAB * 1}output:\n"
                    f'{TAB * 2}"foo.txt",\n'
                    f'{TAB * 2}"bar.txt",\n')

        assert actual == expected