biomedicalinformaticsgroup / Sargasso

Sargasso disambiguates mixed-species high-throughput sequencing data.
http://biomedicalinformaticsgroup.github.io/Sargasso/
Other
8 stars 4 forks source link

get_data_type_manager.get_separator() seems to return the same separator instance other than a new instance #88

Open hxin opened 5 years ago

hxin commented 5 years ago

I was refactoring the teat code to work with the changes in dev branch when I notice a wired error:

I have a test file containing two tests: test_run_chipseq_se_makefile test_run_chipseq_pe_makefile

When running then individually, no error occurred.

pytest  --log-cli-level debug  tests/separator/test_separator.py::test_run_chipseq_se_makefile
pytest  --log-cli-level debug  tests/separator/test_separator.py::test_run_chipseq_pe_makefile

However, when running them together, it seems that the Makefile generated by the second test contains the content of the first Makefile.

 pytest  --log-cli-level debug  tests/separator/test_separator.py

After debugging a bit, it seems that, for some reason, when running the test together, the second _DATA_TYPES is the same instance as the first one. Thus the returned DnaSeqMakefileWriter is the same instance of the first one, resulting in the DnaSeqMakefileWriter.lines variable already contains the first makefile content.

This may due to the face that the _DATA_TYPES is a variable in the file, rather than in a class/instance. I am not sure if this is a bug really but just a python variable scope thing I didn't understand well. Maybe we can chat about this when meet.

@lweasel