4

刚刚安装 py.testpip install -U pytest没有错误,但是我们尝试启动时py.test出现错误:EBUSY: [Resource device]: listdir('C:\\Users\\Administrator\\AppData\\Local\\Application Data',)

这是输出:

C:\Users\Administrator>py.test  
========================== test session starts ===========================  
platform win32 -- Python 2.7.3 -- pytest-2.2.4  
collected 0 items / 1 errors  

================================= ERRORS =================================
___________________________ ERROR collecting . ___________________________  
C:\Python27\lib\site-packages\py\_path\common.py:315: in visit  
>       for x in Visitor(fil, rec, ignore, bf, sort).gen(self):  
C:\Python27\lib\site-packages\py\_path\common.py:361: in gen  
>               for p in self.gen(subdir):  
C:\Python27\lib\site-packages\py\_path\common.py:361: in gen  
>               for p in self.gen(subdir):  
C:\Python27\lib\site-packages\py\_path\common.py:361: in gen  
>               for p in self.gen(subdir):  
C:\Python27\lib\site-packages\py\_path\common.py:346: in gen  
>           entries = path.listdir()  
C:\Python27\lib\site-packages\py\_path\local.py:320: in listdir  
>       for name in py.error.checked_call(os.listdir, self.strpath):  
C:\Python27\lib\site-packages\py\_error.py:83: in checked_call  
>           raise cls("%s%r" % (func.__name__, args))  
E           EBUSY: [Resource device]: listdir('C:\\Users\\Administrator\\Ap 
pData\\Local\\Application Data',)  
======================== 1 error in 0.03 seconds =========================

那会是什么?

谢谢

4

2 回答 2

5

显然,当被调用时,它开始使用标准测试发现规则py.test查看文件/文件夹。并且某些文件夹具有限制访问权限的访问权限,因此会发生此错误。

要使用py.test一个必须首先导航到包含测试用例的文件夹。

于 2012-08-09T19:28:36.803 回答
-1

您创建了一个文件test_cases,但.py您应该重命名您的测试用例文件,例如test_cases.py

于 2020-05-13T02:16:52.337 回答