Skip to content

generate unit test with snakemake but missing quote for configfile in generated test scripts #843

@Grelot

Description

@Grelot

snakemake 5.31.1

I ran my workflow with success a first time

snakemake --configfile config/config_test_rapidrun.yaml -s Snakefile --cores 8 --use-conda

and then I ran again my workflow to generate unit test scripts using --generate-unit-tests

 snakemake --configfile config/config_test_rapidrun.yaml -s Snakefile  --cores 8 --use-conda --generate-unit-tests

I ran pytest3

python3 -m pytest .tests/unit/

Then all the tests failed. It appears that the path of the configfile is not quoted inside the scripts:

Instance of error:

========================================================================== ERRORS ==========================================================================
____________________________________________________ ERROR collecting .tests/unit/test_trim_primers.py _____________________________________________________
../../../miniconda3/envs/snakemake_rapidrun/lib/python3.9/site-packages/_pytest/python.py:578: in _importtestmodule
    mod = import_path(self.fspath, mode=importmode)
../../../miniconda3/envs/snakemake_rapidrun/lib/python3.9/site-packages/_pytest/pathlib.py:531: in import_path
    importlib.import_module(module_name)
../../../miniconda3/envs/snakemake_rapidrun/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1030: in _gcd_import
    ???
<frozen importlib._bootstrap>:1007: in _find_and_load
    ???
<frozen importlib._bootstrap>:986: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:680: in _load_unlocked
    ???
../../../miniconda3/envs/snakemake_rapidrun/lib/python3.9/site-packages/_pytest/assertion/rewrite.py:161: in exec_module
    source_stat, co = _rewrite_test(fn, self.config)
../../../miniconda3/envs/snakemake_rapidrun/lib/python3.9/site-packages/_pytest/assertion/rewrite.py:354: in _rewrite_test
    tree = ast.parse(source, filename=fn_)
../../../miniconda3/envs/snakemake_rapidrun/lib/python3.9/ast.py:50: in parse
    return compile(source, filename, mode, flags,
E     File "/home/pguerin/working/edna/snakemake_rapidrun_swarm/.tests/unit/test_trim_primers.py", line 37
E       /home/pguerin/working/edna/snakemake_rapidrun_swarm/config/config_test_rapidrun.yaml
E       ^
E   SyntaxError: invalid syntax

And the faulty code:

        # Run the test job.
        sp.check_output([
            "python",
            "-m",
            "snakemake",
            "results/04_trim_primers/projet1/chond/sample2.fastq",
            "-F",
            "-j1",
            "--keep-target-files",
            "--configfile",
            /home/pguerin/working/edna/snakemake_rapidrun_swarm/config/config_test_rapidrun.yaml

            "--use-conda",
            "--directory",
            workdir,
        ])

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions