Open reece opened 6 years ago
I found this relevant gist post about modularizing pytest fixtures: How to modularize your py.test fixtures there is a post by ikonst recommending to create a local pytest plugin to store fixtures.
tests/test_hgvs_variantmapper.py and tests/test_hgvs_variantmapper_gcp.py have almost identical setUp() functions and could be replaced with pytest fixtures.
tests/test_hgvs_variantmapper.py
@classmethod def setUpClass(cls): cls.hdp = hgvs.dataproviders.uta.connect(mode=os.environ.get("HGVS_CACHE_MODE", "run"), cache=CACHE) cls.vm = hgvs.variantmapper.VariantMapper(cls.hdp) cls.hp = hgvs.parser.Parser()
tests/test_hgvs_variantmapper_gcp.py
def setUp(self): self.hdp = hgvs.dataproviders.uta.connect(mode=os.environ.get("HGVS_CACHE_MODE", "run"), cache=CACHE) self.hm = hgvs.variantmapper.VariantMapper(self.hdp) self.hp = hgvs.parser.Parser()
These are the minimum number of times we connect or instantiate these objects for tests. (The above excludes cases where we instantiate in loops, if any.)
Instead, use common fixtures that are created once per test session.