hgvs icon indicating copy to clipboard operation
hgvs copied to clipboard

Use pytest fixtures rather than instantiating new conections

Open reece opened this issue 7 years ago • 1 comments

snafu$ for w in 'connect(' VariantMapper AssemblyMapper Normalizer Validator; do printf "%d $w\n" $(fgrep $w tests/*.py|wc -l); done

18 connect(
16 VariantMapper
15 AssemblyMapper
11 Normalizer
10 Validator

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.

reece avatar Jul 26 '18 00:07 reece

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()

jamesBrosnahan avatar Aug 15 '18 22:08 jamesBrosnahan