How to use check_installed method in avocado

Best Python code snippet using avocado_python

test_make_prodigal.py

Source:test_make_prodigal.py Github

copy

Full Screen

...32 """33 # check installed softs before installing panacota34 cmd = "python3 make"35 error = "Error trying to install PanACoTA from base"36 assert not utils.check_installed("barrnap")37 assert utils.check_installed("prodigal")38 assert not utils.check_installed("mash")39 assert not utils.check_installed("PanACoTA")40 # install panacota and check installation41 utils.run_cmd(cmd, error)42 assert not utils.check_installed("barrnap")43 assert not utils.check_installed("mash")44 assert utils.check_installed("prodigal")45 assert utils.check_installed("PanACoTA")46 # Check that dist-info file exists (pip3 has panacota module)47 cmd = "pip3 show PanACoTA"48 err = "error pip3"49 stdout = "stdout_pip3show.out"50 with open(stdout, "w") as stdof:51 utils.run_cmd(cmd, err, stdout=stdof, stderr=stdof)52 with open(stdout, "r") as stdof:53 for line in stdof:54 if line.startswith("Location"):55 loc = line.split()[-1]56 assert glob.glob(os.path.join(loc, r'PanACoTA*dist-info'))57 os.remove(stdout)58 logfile = "install.log"59 content = ["Installing PanACoTA",60 "Some dependencies needed for some subcommands of PanACoTA are "61 "not installed. Here is the list of missing dependencies, and for what they are "62 "used. If you plan to use the subcommands hereafter, first install required "63 "dependencies:",64 "- mmseqs (for pangenome subcommand)",65 "- mafft (to align persistent genomes in order to infer a phylogenetic tree "66 "after)",67 "- mash (for prepare subcommand, to filter genomes)",68 "- prokka (for annotate subcommand, with syntaxic + functional annotation). "69 "If you only need syntaxic annotation, prodigal is enough.",70 "- barrnap. If you use Prokka for functional annotation, it will not predict RNA.",71 "- One of the 4 following softwares, used to infer a phylogenetic tree:",72 "* FastTree (see README or documentation for more information on how to "73 "install it)", "* FastME", "* Quicktree", "* IQtree (or IQtree2)"]74 # Check output logfile content. Check that all content is present, in any order.75 with open(logfile, "r") as logf:76 logf_content = "".join(logf.readlines())77 for linec in content:78 assert linec in logf_content79 # Check that needed packages are installed80 assert utils.is_package_installed("argparse")81 assert utils.is_package_installed("progressbar")82 assert utils.is_package_installed("numpy")83 assert utils.is_package_installed("matplotlib")84 assert utils.is_package_installed("Bio")85def test_upgrade(install_panacota):86 """87 Test upgrading PanACoTA when dependencies (only prodigal) are still installed88 # """89 assert not utils.check_installed("barrnap")90 assert not utils.check_installed("prokka")91 assert utils.check_installed("PanACoTA")92 assert utils.check_installed("prodigal")93 cmd = "python3 make upgrade"94 error = "Error upgrade"95 utils.run_cmd(cmd, error)96 assert not utils.check_installed("barrnap")97 assert not utils.check_installed("prokka")98 assert utils.check_installed("prodigal")99 assert utils.check_installed("PanACoTA")100 logfile = "install.log"101 with open(logfile, "r") as logf:102 lines = logf.readlines()103 assert len(lines) == 2104 assert "Upgrading PanACoTA" in lines[0]105 assert "DONE" in lines[1]106def test_uninstall(install_panacota):107 """108 Test uninstalling PanACoTA109 """110 assert utils.check_installed("prodigal")111 assert not utils.check_installed("barrnap")112 assert not utils.check_installed("prokka")113 assert utils.check_installed("PanACoTA")114 cmd = "python3 make uninstall"115 error = "Error uninstalling"116 utils.run_cmd(cmd, error)117 assert utils.check_installed("prodigal")118 assert not utils.check_installed("prokka")119 assert not utils.check_installed("barrnap")120 assert not utils.check_installed("PanACoTA")121 logfile = "install.log"122 with open(logfile, "r") as logf:123 lines = logf.readlines()124 assert len(lines) == 2125 assert ":: INFO :: Uninstalling PanACoTA" in lines[0]126 assert "DONE" in lines[1]127def test_develop():128 """129 Test installing PanACoTA in developer mode, when prodigal is already installed130 """131 assert not utils.check_installed("PanACoTA")132 assert utils.check_installed("prodigal")133 assert not utils.check_installed("prokka")134 assert not utils.check_installed("barrnap")135 cmd = "python3 make develop"136 error = "Error develop"137 utils.run_cmd(cmd, error)138 assert utils.check_installed("PanACoTA")139 assert utils.check_installed("prodigal")140 assert not utils.check_installed("prokka")141 assert not utils.check_installed("barrnap")142 cmd = "pip3 show PanACoTA"143 err = "error pip3"144 stdout = "stdout_pip3show.out"145 with open(stdout, "w") as stdof:146 utils.run_cmd(cmd, err, stdout=stdof, stderr=stdof)147 with open(stdout, "r") as stdof:148 for line in stdof:149 if line.startswith("Location"):150 loc = line.split()[-1]151 assert glob.glob(os.path.join(loc, r'PanACoTA*egg-info'))152 os.remove(stdout)153 logfile = "install.log"154 content = ["Installing developer packages needed for PanACoTA",155 "- mash (for prepare subcommand, to filter genomes)",156 "Some dependencies needed for some subcommands of PanACoTA are "157 "not installed. Here is the list of missing dependencies, and for what they are "158 "used. If you plan to use the subcommands hereafter, first install required "159 "dependencies:",160 "- mmseqs (for pangenome subcommand)",161 "- barrnap. If you use Prokka for functional annotation, it will not predict RNA.",162 "- mafft (to align persistent genomes in order to infer a phylogenetic tree "163 "after)",164 "- prokka (for annotate subcommand, with syntaxic + functional annotation). "165 "If you only need syntaxic annotation, prodigal is enough.",166 "- One of the 4 following softwares, used to infer a phylogenetic tree:",167 "* FastTree (see README or documentation for more information on how to "168 "install it)", "* FastME", "* Quicktree", "* IQtree (or IQtree2)", "DONE"]169 # Check output logfile content. Check that all content is present, in any order.170 with open(logfile, "r") as logf:171 logf_content = "".join(logf.readlines())172 for linec in content:173 assert linec in logf_content174 # Check that needed packages are installed175 assert utils.is_package_installed("argparse")176 assert utils.is_package_installed("progressbar")177 assert utils.is_package_installed("numpy")178 assert utils.is_package_installed("matplotlib")179 assert utils.is_package_installed("Bio")180 assert utils.is_package_installed("sphinx")181 assert utils.is_package_installed("coverage")182def test_install_user():183 """184 Test that when installing from a computer in user mode, it really installs185 PanACoTA in user mode186 """187 assert utils.check_installed("prodigal")188 assert not utils.check_installed("barrnap")189 assert not utils.check_installed("prokka")190 assert not utils.check_installed("PanACoTA")191 cmd = "python3 make --user"192 error = "Error trying to install PanACoTA from base"193 utils.run_cmd(cmd, error)194 assert utils.check_installed("prodigal")195 assert not utils.check_installed("prokka")196 assert not utils.check_installed("barrnap")197 assert utils.check_installed("PanACoTA")198 # Check logfile content199 logfile = "install.log"200 content = ["Installing PanACoTA in user mode...",201 "Some dependencies needed for some subcommands of PanACoTA are "202 "not installed. Here is the list of missing dependencies, and for what they are "203 "used. If you plan to use the subcommands hereafter, first install required "204 "dependencies:",205 "- mash (for prepare subcommand, to filter genomes)",206 "- mmseqs (for pangenome subcommand)",207 "- barrnap. If you use Prokka for functional annotation, it will not predict RNA.",208 "- mafft (to align persistent genomes in order to infer a phylogenetic tree "209 "after)",210 "- prokka (for annotate subcommand, with syntaxic + functional annotation). "211 "If you only need syntaxic annotation, prodigal is enough.",...

Full Screen

Full Screen

test_make_prokka-quicktree.py

Source:test_make_prokka-quicktree.py Github

copy

Full Screen

...27 """28 Test that when installing from a computer containing only prokka and quicktree, it installs29 PanACoTA, and returns the list of missing dependencies30 """31 assert not utils.check_installed("barrnap")32 assert not utils.check_installed("prodigal")33 assert utils.check_installed("quicktree")34 assert not utils.check_installed("iqtree")35 assert utils.check_installed("prokka")36 assert not utils.check_installed("PanACoTA")37 assert utils.check_installed('quicktree')38 cmd = "python3 make"39 error = "Error trying to install PanACoTA from base"40 utils.run_cmd(cmd, error)41 assert not utils.check_installed("barrnap")42 assert utils.check_installed("prokka")43 assert utils.check_installed("PanACoTA")44 assert utils.check_installed('quicktree')45 cmd = "pip3 show PanACoTA"46 err = "error pip3"47 stdout = "stdout_pip3show.out"48 with open(stdout, "w") as stdof:49 utils.run_cmd(cmd, err, stdout=stdof, stderr=stdof)50 with open(stdout, "r") as stdof:51 for line in stdof:52 if line.startswith("Location"):53 loc = line.split()[-1]54 assert glob.glob(os.path.join(loc, r'PanACoTA*dist-info'))55 os.remove(stdout)56 logfile = "install.log"57 content = ["Installing PanACoTA...", "DONE",58 "Some dependencies needed for some subcommands of PanACoTA are "59 "not installed. Here is the list of missing dependencies, and for what they are "60 "used. If you plan to use the subcommands hereafter, first install required "61 "dependencies:",62 "- mmseqs (for pangenome subcommand)",63 "- mash (for prepare subcommand, to filter genomes)",64 "- mafft (to align persistent genomes in order to infer a phylogenetic tree "65 "after)",66 "See more information on how to download/install those softwares in README or in "67 "documentation.",68 "- barrnap. If you use Prokka for functional annotation, it will not predict RNA."69 ]70 with open(logfile, "r") as logf:71 logf_content = "".join(logf.readlines())72 for linec in content:73 assert linec in logf_content74 # Check that needed packages are installed75 assert utils.is_package_installed("argparse")76 assert utils.is_package_installed("progressbar")77 assert utils.is_package_installed("numpy")78 assert utils.is_package_installed("matplotlib")79 assert utils.is_package_installed("Bio")80 os.remove(logfile)81def test_upgrade(install_panacota):82 """83 Test upgrading PanACoTA when dependencies are still installed84 """85 assert not utils.check_installed("barrnap")86 assert utils.check_installed("prokka")87 assert utils.check_installed("PanACoTA")88 assert utils.check_installed('quicktree')89 cmd = "python3 make upgrade"90 error = "Error upgrade"91 utils.run_cmd(cmd, error)92 assert not utils.check_installed("barrnap")93 assert utils.check_installed("prokka")94 assert utils.check_installed("PanACoTA")95 assert utils.check_installed('quicktree')96 logfile = "install.log"97 with open(logfile, "r") as logf:98 lines = logf.readlines()99 assert len(lines) == 2100 assert "Upgrading PanACoTA" in lines[0]101 assert "DONE" in lines[1]102def test_uninstall_withdep(install_panacota):103 """104 Test uninstalling PanACoTA when dependencies are still installed105 """106 assert not utils.check_installed("barrnap")107 assert utils.check_installed("prokka")108 assert utils.check_installed("quicktree")109 assert utils.check_installed("PanACoTA")110 cmd = "python3 make uninstall"111 error = "Error uninstalling"112 utils.run_cmd(cmd, error)113 assert not utils.check_installed("barrnap")114 assert utils.check_installed("prokka")115 assert not utils.check_installed("PanACoTA")116 assert utils.check_installed('quicktree')117def test_develop():118 """119 Test installing PanACoTA in developer mode, when prokka and barrnap are already installed120 """121 assert not utils.check_installed("PanACoTA")122 assert not utils.check_installed("barrnap")123 assert utils.check_installed('quicktree')124 assert utils.check_installed("prokka")125 cmd = "python3 make develop"126 error = "Error develop"127 utils.run_cmd(cmd, error)128 assert not utils.check_installed("barrnap")129 assert utils.check_installed("prokka")130 assert utils.check_installed("PanACoTA")131 assert utils.check_installed('quicktree')132 cmd = "pip3 show PanACoTA"133 err = "error pip3"134 stdout = "stdout_pip3show.out"135 with open(stdout, "w") as stdof:136 utils.run_cmd(cmd, err, stdout=stdof, stderr=stdof)137 # Check installation in develop mode138 with open(stdout, "r") as stdof:139 for line in stdof:140 if line.startswith("Location"):141 loc = line.split()[-1]142 assert glob.glob(os.path.join(loc, r'PanACoTA*egg-info'))143 os.remove(stdout)144 logfile = "install.log"145 content = ["Installing PanACoTA...",146 "Installing developer packages needed for PanACoTA",147 "Some dependencies needed for some subcommands of PanACoTA are "148 "not installed. Here is the list of missing dependencies, and for what they are "149 "used. If you plan to use the subcommands hereafter, first install required "150 "dependencies:",151 "- mmseqs (for pangenome subcommand)",152 "- mafft (to align persistent genomes in order to infer a phylogenetic tree "153 "after)",154 "- mash (for prepare subcommand, to filter genomes)",155 "- barrnap. If you use Prokka for functional annotation, it will not predict RNA.",156 "See more information on how to download/install those softwares in README or in "157 "documentation."]158 with open(logfile, "r") as logf:159 logf_content = "".join(logf.readlines())160 for linec in content:161 assert linec in logf_content162 # Check that needed packages are installed163 assert utils.is_package_installed("argparse")164 assert utils.is_package_installed("progressbar")165 assert utils.is_package_installed("numpy")166 assert utils.is_package_installed("matplotlib")167 assert utils.is_package_installed("Bio")168 os.remove(logfile)169def test_install_user():170 """171 Test that when installing from a computer containing only prokka, in user mode, it installs172 PanACoTA in /Users and returns list of dependencies173 """174 assert not utils.check_installed("barrnap")175 assert not utils.check_installed("mash")176 assert utils.check_installed("prokka")177 assert utils.check_installed("quicktree")178 assert not utils.check_installed("PanACoTA")179 cmd = "python3 make --user"180 error = "Error trying to install PanACoTA from base"181 utils.run_cmd(cmd, error)182 assert not utils.check_installed("barrnap")183 assert not utils.check_installed("mash")184 assert utils.check_installed("prokka")185 assert utils.check_installed("quicktree")186 assert utils.check_installed("PanACoTA")187 # Check logfile content188 logfile = "install.log"189 content = ["Installing PanACoTA in user mode...",190 "Some dependencies needed for some subcommands of PanACoTA are "191 "not installed. Here is the list of missing dependencies, and for what they are "192 "used. If you plan to use the subcommands hereafter, first install required "193 "dependencies:",194 "- mmseqs (for pangenome subcommand)",195 "- mafft (to align persistent genomes in order to infer a phylogenetic tree "196 "after)",197 "- mash (for prepare subcommand, to filter genomes)",198 "See more information on how to download/install those softwares in README or in "199 "documentation."]200 with open(logfile, "r") as logf:...

Full Screen

Full Screen

test_make_all-installed.py

Source:test_make_all-installed.py Github

copy

Full Screen

...30 Test that when installing from a computer containing only all dependencies, it returns a message without any warning: everything is ok31 """32 cmd = "python3 make"33 error = "Error trying to install PanACoTA from base"34 assert not utils.check_installed("PanACoTA")35 assert utils.check_installed("barrnap")36 assert utils.check_installed("prokka")37 assert utils.check_installed("mash")38 assert utils.check_installed("FastTreeMP")39 # Install panacota40 utils.run_cmd(cmd, error)41 assert utils.check_installed("PanACoTA")42 assert utils.check_installed("barrnap")43 assert utils.check_installed("prokka")44 assert utils.check_installed("mash")45 assert utils.check_installed("FastTreeMP")46 # Check that panacota is installed (pip3 module exists)47 assert utils.is_package_installed("PanACoTA")48 # Check that it is installed in "final mode"49 cmd = "pip3 show PanACoTA"50 err = "error pip3"51 stdout = "stdout_pip3show.out"52 with open(stdout, "w") as stdof:53 utils.run_cmd(cmd, err, stdout=stdof, stderr=stdof)54 with open(stdout, "r") as stdof:55 for line in stdof:56 if line.startswith("Location"):57 loc = line.split()[-1]58 assert glob.glob(os.path.join(loc, r'PanACoTA*dist-info'))59 os.remove(stdout)60 # Check not installed in user mode61 cmd = "pip list --user"62 list_user_packages = str(subprocess.check_output(shlex.split(cmd)))63 assert "PanACoTA" not in list_user_packages64 # Check output logfile content. Check that all content is present, in any order.65 logfile = "install.log"66 content = ["Installing PanACoTA...", "DONE"]67 with open(logfile, "r") as logf:68 logf_content = "".join(logf.readlines())69 for linec in content:70 assert linec in logf_content71 # Check that needed packages are installed72 assert utils.is_package_installed("argparse")73 assert utils.is_package_installed("progressbar")74 assert utils.is_package_installed("numpy")75 assert utils.is_package_installed("matplotlib")76 assert utils.is_package_installed("Bio")77 print("test_installed done")78def test_upgrade(install_panacota):79 """80 Test upgrading PanACoTA when dependencies are still installed81 """82 assert utils.check_installed("barrnap")83 assert utils.check_installed("prokka")84 assert utils.check_installed("FastTreeMP")85 assert utils.check_installed("PanACoTA")86 # Upgrade PanACoTA87 cmd = "python3 make upgrade"88 error = "Error upgrade"89 utils.run_cmd(cmd, error)90 assert utils.check_installed("barrnap")91 assert utils.check_installed("prokka")92 assert utils.check_installed("PanACoTA")93 assert utils.check_installed("FastTreeMP")94 logfile = "install.log"95 with open(logfile, "r") as logf:96 lines = logf.readlines()97 assert len(lines) == 298 assert "Upgrading PanACoTA" in lines[0]99 assert "DONE" in lines[1]100 print("test_upgrade done")101def test_upgrade_notinstalled():102 """103 Test upgrading PanACoTA when dependencies are not installed (only barrnap),104 and PanACoTA is not installed. It just installs PanACoTA, without prokka dep105 """106 assert utils.check_installed("barrnap")107 assert utils.check_installed("prokka")108 assert utils.check_installed("FastTreeMP")109 assert not utils.check_installed("PanACoTA")110 cmd = "python3 make upgrade"111 error = "Error upgrade"112 utils.run_cmd(cmd, error)113 assert utils.check_installed("barrnap")114 assert utils.check_installed("prokka")115 assert utils.check_installed("PanACoTA")116 assert utils.check_installed("FastTreeMP")117 logfile = "install.log"118 with open(logfile, "r") as logf:119 lines = logf.readlines()120 assert len(lines) == 2121 assert "Upgrading PanACoTA" in lines[0]122 assert "DONE" in lines[1]123 os.remove(logfile)124 print("test_upgrade_notinstalled done")125def test_uninstall(install_panacota):126 """127 Test uninstalling PanACoTA when dependencies are still installed128 """129 assert utils.check_installed("barrnap")130 assert utils.check_installed("prokka")131 assert utils.check_installed("PanACoTA")132 assert utils.check_installed("FastTreeMP")133 cmd = "python3 make uninstall"134 error = "Error uninstalling"135 utils.run_cmd(cmd, error)136 assert not utils.check_installed("PanACoTA")137 assert utils.check_installed("barrnap")138 assert utils.check_installed("prokka")139 assert utils.check_installed("mash")140 assert utils.check_installed("FastTreeMP")141 assert utils.check_installed("quicktree")142 assert utils.check_installed("iqtree") or utils.check_installed("iqtree2")143 logfile = "install.log"144 with open(logfile, "r") as logf:145 lines = logf.readlines()146 assert len(lines) == 2147 assert "Uninstalling PanACoTA" in lines[0]148 assert "DONE" in lines[1]149 print("test_uninstall done")150def test_develop():151 """152 Test installing PanACoTA in developer mode, when prokka and barrnap are already installed153 """154 assert not utils.check_installed("PanACoTA")155 assert utils.check_installed("barrnap")156 assert utils.check_installed("prokka")157 cmd = "python3 make develop"158 error = "Error develop"159 utils.run_cmd(cmd, error)160 assert utils.check_installed("barrnap")161 assert utils.check_installed("prokka")162 assert utils.check_installed("PanACoTA")163 # Check installed in developper mode (egg-info file is present)164 cmd = "pip3 show PanACoTA"165 err = "error pip3"166 stdout = "stdout_pip3show.out"167 with open(stdout, "w") as stdof:168 utils.run_cmd(cmd, err, stdout=stdof, stderr=stdof)169 # Check installation in develop mode170 with open(stdout, "r") as stdof:171 lines = stdof.readlines()172 for line in lines:173 if line.startswith("Location"):174 loc = line.split()[-1]175 assert glob.glob(os.path.join(loc, r'PanACoTA*egg-info'))176 os.remove(stdout)177 # Check not installed in user mode178 cmd = "pip list --user"179 list_user_packages = str(subprocess.check_output(shlex.split(cmd)))180 assert "PanACoTA" not in list_user_packages181 # check logfile content182 logfile = "install.log"183 content = ["Installing PanACoTA...",184 "Installing developer packages needed for PanACoTA", "DONE"]185 with open(logfile, "r") as logf:186 logf_content = "".join(logf.readlines())187 for linec in content:188 assert linec in logf_content189 # Check that needed packages are installed190 assert utils.is_package_installed("argparse")191 assert utils.is_package_installed("progressbar")192 assert utils.is_package_installed("numpy")193 assert utils.is_package_installed("matplotlib")194 assert utils.is_package_installed("Bio")195 assert utils.is_package_installed("sphinx")196 assert utils.is_package_installed("numpydoc")197 assert utils.is_package_installed("pytest")198 assert utils.is_package_installed("coverage")199 print("test_develop done")200def test_install_user():201 """202 Test that when installing from a computer in user mode, it really installs203 PanACoTA in user mode (pip showing PanACoTA when asking for user installed packages)204 """205 cmd = "python3 make --user"206 error = "Error trying to install PanACoTA from base"207 assert utils.check_installed("barrnap")208 assert utils.check_installed("prokka")209 assert not utils.check_installed("PanACoTA")210 assert utils.check_installed("FastTreeMP")211 utils.run_cmd(cmd, error)212 assert utils.check_installed("barrnap")213 assert utils.check_installed("prokka")214 assert utils.check_installed("PanACoTA")215 assert utils.check_installed("FastTreeMP")216 # Check logfile content217 logfile = "install.log"218 content = ["Installing PanACoTA in user mode...", "DONE"]219 with open(logfile, "r") as logf:220 logf_content = "".join(logf.readlines())221 for linec in content:222 assert linec in logf_content223 # Check that needed packages are installed224 assert utils.is_package_installed("argparse")225 assert utils.is_package_installed("progressbar")226 assert utils.is_package_installed("numpy")227 assert utils.is_package_installed("matplotlib")...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful