pepkit / looper

A job submitter for Portable Encapsulated Projects
http://looper.databio.org
BSD 2-Clause "Simplified" License
20 stars 7 forks source link

Looper pytesting sometimes does not clean up .looper.yaml file causing false positive in testing #364

Closed donaldcampbelljr closed 11 months ago

donaldcampbelljr commented 1 year ago
__ LooperBothRunsTests.test_run_afterinit[runp] __

self = <tests.smoketests.test_run.LooperBothRunsTests object at 0x7faaddf67f40>, prep_temp_pep = '/tmp/tmp797z770l/project_config.yaml', cmd = 'runp'

    @pytest.mark.parametrize("cmd", ["run", "runp"])
    def test_run_after_init(self, prep_temp_pep, cmd):
        tp = prep_temp_pep
        dotfile_path = os.path.join(os.getcwd(), LOOPER_DOTFILE_NAME)
        stdout, stderr, rc = subp_exec(tp, "init")
        print(stderr)
        print(stdout)
      assert rc == 0
E       assert 1 == 0

tests/smoketests/test_run.py:69: AssertionError
------------------------------------------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------------------------------------------
b''
b"Can't initialize, file exists: /home/aaronobrien/projects/looper/.looper.yaml\n

A dot file will remain in the looper folder that, if not removed manually, will cause false positive during pytesting.

donaldcampbelljr commented 1 year ago

There is a function initialize the dot file: https://github.com/pepkit/looper/blob/02c7b8e2dd259cf42621e3c41195af70a2795fc7/looper/utils.py#L315-L338

And this test function from test_run.py should be removing the dot file: https://github.com/pepkit/looper/blob/02c7b8e2dd259cf42621e3c41195af70a2795fc7/tests/smoketests/test_run.py#L63-L75

nsheff commented 1 year ago

This seems like it might be a good candidate for using a context manager

nsheff commented 11 months ago

https://github.com/databio/markmeld/blob/10fa6a7e069ab7e216c18a75c558c196f3d0b1a2/tests/test_markmeld.py#L37-L41C24