草庐IT

package_test

全部标签

Python anaconda conda 问题 : updating anaconda package impossible because processes are running

我在使用conda更新anaconda的包时遇到问题。当我进行condaupdate--all时,有一个问题对我说:Error:Unabletoremovefilesforpackage:cryptographyPleasecloseallprocessesrunningcodefromcryptographyandtryagain.但是,没有进程在运行,我只是打开了cmd窗口。例如,当我想要更新dateutile时,情况相同。就像conda使用了一些包然后我无法更新它们一样?有人知道关闭或删除这些软件包以重新安装它们的方法吗?信息:C:\Anaconda3\Scripts>conda

Python 单元测试 : cancel all tests if a specific test fails

我正在使用unittest来测试我的Flask应用程序,并使用nose来实际运行测试。我的第一组测试是为了确保测试环境干净,并防止在Flask应用程序配置的数据库上运行测试。我确信我已经干净地设置了测试环境,但我希望在不运行所有测试的情况下对此有一些保证。importunittestclassMyTestCase(unittest.TestCase):defsetUp(self):#setsomestuffuppassdeftearDown(self):#dotheteardownpassclassTestEnvironmentTest(MyTestCase):deftest_envi

python - 如何让 Travis CI 安装 tests_require 中声明的 Python 依赖项?

我有带有setup.py的Python包。它具有在install_requires中声明的常规依赖项和在tests_require中声明的开发依赖项,例如flake8.我认为pipinstall-e.或运行pythonsetup.pytest也会安装我的开发依赖项,它们将可用。然而,显然它们不是,我很难正确设置我的TravisCI构建。install:-"pipinstall-e."script:-"pythonsetup.pytest"-"flake8"如上配置的构建将失败,因为flake8将不会被发现为有效命令。我还尝试从pythonsetup.pytest命令内部调用flake8

python - 在子文件夹中使用 pytest where test

我正在使用pythonpytest来运行我的单元测试。我的项目文件夹是:Main-包含数据文件:A.txtMain\Tests-我运行pytest的文件夹Main\Tests\A_test-包含测试文件的文件夹A_test文件夹中的测试使用文件A.txt(位于Main文件夹中)。我的问题是,当我运行py.test时,测试失败,因为它找不到A.txt。我发现是因为pytest在运行测试时使用了路径Main\Test,而不是将路径改为Main\Tests\A_test(我是在测试文件中打开A.txt时使用相对路径)我的问题:有没有办法让pytest将目录更改为它为每个测试执行的测试文件夹?

python - 使用 if __name__ == '__main__' : for tests

当您编写一些自给自足的脚本时,使用if__name__=='__main__'作为编写测试的地方是不是一个坏主意? 最佳答案 这实际上取决于您的代码和脚本的目的。对于大型和复杂的项目,您肯定必须将所有测试放在一个单独的地方。但是在处理一些小的事情时,将测试与代码一起进行可能是一个很好的解决方案-这是doctest的主要思想(这是一个很棒的Python模块,允许您在文档字符串中编写测试)。在这种情况下,您的if__name__=='__main__'将如下所示:if__name__=="__main__":importdoctestd

python - Mac 操作系统, pip : specify compiler for packages containing C libraries

我在使用pip使用默认的clang编译器编译mapscript(是来自pypi的包含C代码的包)时遇到了一些问题。这是我的尝试:-$sudopipinstallmapscriptPassword:Downloading/unpackingmapscriptRunningsetup.pyegg_infoforpackagemapscriptRequirementalreadysatisfied(use--upgradetoupgrade):distributein/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib

python - "PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.5/site-packages '"安装Django

我无法在Ubuntu上安装基本的Django包。我刚刚删除了virtualenv并重新制作了它。pip3install=pip3install-rrequirements.txt[mything]cchilders@cchilders-desktop:~/projects/mything(master)$catrequirements.txtDjango==1.10.1django-filterdjangorestframeworkpsycopg2twilioipdbipython[mything]cchilders@cchilders-desktop:~/projects/mythi

python - 从 Python 解释器运行时获取 "ImportError: attempted relative import with no known parent package"

我正在使用Flask创建模块化应用blueprints特征。结果,我的目录结构是这样的:project__init__.pyconfig.pymould.pymodules__init__.pycore__init__.pycore.pydb.pymodels.py不要将此处的模块目录与Python模块混淆,它们用于为我的项目提供模块化结构(核心模块、foo模块、bar模块等)。现在,模块目录中的每个文件夹(以及其中的同名模块,例如core.core)都动态导入到我的主flask应用程序(mould.py)中这样做:foriteminos.listdir("modules"):ifno

python - python 的新 'pip wheel' 是否支持为 tests_requires 中列出的依赖项构建轮子?

我使用setuptools'tests_require'来指定测试我的包所需的依赖项。tests_require-http://pythonhosted.org/distribute/setuptools.html#new-and-changed-setup-keywords我已经开始使用wheelpackaginghttp://wheel.readthedocs.org/en/latest/并为我当前的包及其所有依赖项构建一个wheels目录。pipwheel--wheel-dir=/tmp/wheelhouse.不过,我还想为任何包tests_require中列出的所有包构建轮子。

python - python2 存在 site-packages 文件夹,python3 不存在

作为root用户,我看到:root@5d6f29f1d4e9:/usr/local/lib/python2.7#ls-a...dist-packagessite-packagesroot@5d6f29f1d4e9:/usr/local/lib/python3.6#ls-a...dist-packages当我运行这个时:find/-typed-name'site-packages'唯一的结果是:/usr/local/lib/python2.7/site-packages有谁知道为什么我在3.6中看不到站点包?我安装了python3:aptinstall-ybuild-essentiall