Best Python code snippet using slash
test_05_plugin.py
Source:test_05_plugin.py
2import genomepy.plugins3@pytest.fixture4def deactivate_plugins():5 # save originally active plugins6 original_plugins = [p.name for p in genomepy.plugins.get_active_plugins()]7 # deactivate all plugins8 [genomepy.plugins.deactivate(p) for p in original_plugins]9 yield10 # reactivate original plugins11 [genomepy.plugins.activate(p) for p in original_plugins]12def test_plugin():13 p = genomepy.plugins.Plugin()14 assert p.name == "plugin"15 for class_method in [16 "activate",17 "deactivate",18 "after_genome_download",19 "get_properties",20 ]:21 assert class_method in dir(p)22 assert p.active is False23 p.activate()24 assert p.active is True25def test_convert(name="TestName", expected="test_name"):26 result = genomepy.plugins.convert(name)27 assert result == expected28def test_list_plugins():29 plugins = genomepy.plugins.list_plugins()30 expected = ["blacklist", "bowtie2", "bwa", "gmap", "hisat2", "minimap2", "star"]31 assert sorted(plugins) == sorted(expected)32def test_init_plugins():33 p = genomepy.plugins.init_plugins()34 assert isinstance(p, dict)35 plugins = list(p.keys())36 expected = ["blacklist", "bowtie2", "bwa", "gmap", "hisat2", "minimap2", "star"]37 assert sorted(plugins) == sorted(expected)38def test_get_active_plugins(deactivate_plugins):39 _ = deactivate_plugins40 # returns list of all active plugins41 genomepy.plugins.activate("bwa")42 active_plugins = genomepy.plugins.get_active_plugins()43 assert isinstance(active_plugins, list)44 assert ["bwa"] == [p.name for p in active_plugins]45def test_activate(deactivate_plugins):46 _ = deactivate_plugins47 assert len(genomepy.plugins.get_active_plugins()) == 048 genomepy.plugins.activate("bwa")49 assert len(genomepy.plugins.get_active_plugins()) == 150 genomepy.plugins.deactivate("bwa")51def test_deactivate(deactivate_plugins):52 _ = deactivate_plugins53 genomepy.plugins.activate("bwa")54 assert len(genomepy.plugins.get_active_plugins()) == 155 genomepy.plugins.deactivate("bwa")56 assert len(genomepy.plugins.get_active_plugins()) == 057def test_manage_plugins(capsys):58 genomepy.plugins.manage_plugins("enable", ["blacklist"])59 genomepy.plugins.manage_plugins("list")60 captured = capsys.readouterr().out.strip().split("\n")61 assert captured[2].startswith("blacklist")62 assert captured[2].endswith("*")63 genomepy.plugins.manage_plugins("disable", ["blacklist"])64 genomepy.plugins.manage_plugins("list")65 captured = capsys.readouterr().out.strip().split("\n")66 assert captured[2].startswith("blacklist")67 assert not captured[2].endswith("*")68 with pytest.raises(ValueError):...
plugins.py
Source:plugins.py
...4register = template.Library()5@register.simple_tag(takes_context=False)6def get_plugins_js_includes():7 # Flatten all urls for all plugins8 js_urls = list(itertools.chain(*[plugin.get_include_js_urls() for plugin in get_active_plugins()]))9 return "\n".join(map(lambda url: "<script src='{}'></script>".format(url), js_urls))10@register.simple_tag(takes_context=False)11def get_plugins_css_includes():12 # Flatten all urls for all plugins13 css_urls = list(itertools.chain(*[plugin.get_include_css_urls() for plugin in get_active_plugins()]))14 return "\n".join(map(lambda url: "<link href='{}' rel='stylesheet' type='text/css'>".format(url), css_urls))15@register.simple_tag()16def get_plugins_main_menus():17 # Flatten list of menus...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!