我有一个构建脚本来运行一个简单的 python 应用程序。我正在尝试将其设置为任何已安装 conda 并在其 PATH 中的用户都可以运行它。没有其他先决条件。我已经基本完成了这一点,但希望提高回访用户的效率。
构建运行.sh
conda init bash
conda env create --name RUN_ENV --file ../run_env.yml -q --force
conda activate RUN_ENV
python run_app.py
conda deactivate
Run Code Online (Sandbox Code Playgroud)
我想让脚本检查 RUN_ENV 是否已经存在并激活它,而不是每次都强制创建它。我试过
ENVS=$(conda env list | awk '{print }' )
if [[ conda env list = *"RUN_ENV"* ]]; then
conda activate RUN_ENV
else
conda env create --name RUN_ENV --file ../run_env.yml -q
conda activate RUN_ENV
exit
fi;
python run_app.py
conda deactivate
Run Code Online (Sandbox Code Playgroud)
但它总是返回 false 并尝试创建 RUN_ENV
我正在尝试使用 pytest-html 和 selenium 生成一个独立的 html 报告。我一直在尝试将屏幕截图嵌入到报告中,但它们没有显示。\n
我的 conftest.py 看起来像这样
\n@pytest.fixture()\ndef chrome_driver_init(request, path_to_chrome):\n driver = webdriver.Chrome(options=opts, executable_path=path_to_chrome)\n request.cls.driver = driver\n page_object_init(request, driver)\n driver.get(URL)\n driver.maximize_window()\n yield driver\n driver.quit()\n\n\n# Hook that takes a screenshot of the web browser for failed tests and adds it to the HTML report\n@pytest.hookimpl(hookwrapper=True)\ndef pytest_runtest_makereport(item):\n pytest_html = item.config.pluginmanager.getplugin("html")\n outcome = yield\n report = outcome.get_result()\n extra = getattr(report, "extra", [])\n if report.when == "call":\n feature_request = item.funcargs[\'request\']\n driver = feature_request.getfixturevalue(\'chrome_driver_init\')\n nodeid = item.nodeid\n xfail = hasattr(report, "wasxfail")\n …Run Code Online (Sandbox Code Playgroud)