Python pathlib.py:实例化&x27;PosixPath';在窗户上

Python pathlib.py:实例化&x27;PosixPath';在窗户上,python,python-3.x,windows,posix,pathlib,Python,Python 3.x,Windows,Posix,Pathlib,我从(这是真实的项目名称,是的,我知道…)克隆了buck的源代码。尝试通过以下命令安装它以进行开发: pip install -r requirements.txt python setup.py develop 它工作得很好。之后,尝试通过以下方式运行测试: py.test 出现以下错误: ================================== FAILURES =================================== _____________________

我从(这是真实的项目名称,是的,我知道…)克隆了buck的源代码。尝试通过以下命令安装它以进行开发:

pip install -r requirements.txt
python setup.py develop
它工作得很好。之后,尝试通过以下方式运行测试:

py.test
出现以下错误:

================================== FAILURES ===================================
_______________________________ test_load_rule ________________________________

mocker = <pytest_mock.MockFixture object at 0x03275A10>

    def test_load_rule(mocker):
        match = object()
        get_new_command = object()
        load_source = mocker.patch(
            'thefuck.main.load_source',
            return_value=Mock(match=match,
                              get_new_command=get_new_command,
                              enabled_by_default=True,
                              priority=900))
        assert main.load_rule(Path('/rules/bash.py')) \
               == Rule('bash', match, get_new_command, priority=900)
>       load_source.assert_called_once_with('bash', '/rules/bash.py')

tests\test_main.py:20:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Python34\lib\unittest\mock.py:782: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

_mock_self = <MagicMock name='load_source' id='52977776'>
args = ('bash', '/rules/bash.py'), kwargs = {}
expected = (('bash', '/rules/bash.py'), {})
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_me
ssage at 0x032A1030>
actual = call('bash', '\\rules\\bash.py'), cause = None

    def assert_called_with(_mock_self, *args, **kwargs):
        """assert that the mock was called with the specified arguments.

            Raises an AssertionError if the args and keyword args passed in are
            different to the last call to the mock."""
        self = _mock_self
        if self.call_args is None:
            expected = self._format_mock_call_signature(args, kwargs)
            raise AssertionError('Expected call: %s\nNot called' % (expected,))

        def _error_message():
            msg = self._format_mock_failure_message(args, kwargs)
            return msg
        expected = self._call_matcher((args, kwargs))
        actual = self._call_matcher(self.call_args)
        if expected != actual:
            cause = expected if isinstance(expected, Exception) else None
>           raise AssertionError(_error_message()) from cause
E           AssertionError: Expected call: load_source('bash', '/rules/bash.py')

E           Actual call: load_source('bash', '\\rules\\bash.py')

C:\Python34\lib\unittest\mock.py:771: AssertionError
__________________ TestGetRules.test_get[conf_rules0-rules0] __________________

self = <tests.test_main.TestGetRules object at 0x03286F50>
monkeypatch = <_pytest.monkeypatch.monkeypatch object at 0x03286CD0>
glob = <MagicMock name='glob' id='52981200'>, conf_rules = []
rules = ['bash', 'lisp', 'bash', 'lisp']

    @pytest.mark.parametrize('conf_rules, rules', [
        (conf.DEFAULT_RULES, ['bash', 'lisp', 'bash', 'lisp']),
        (types.RulesNamesList(['bash']), ['bash', 'bash'])])
    def test_get(self, monkeypatch, glob, conf_rules, rules):
>       glob.return_value = [PosixPath('bash.py'), PosixPath('lisp.py')]

tests\test_main.py:35:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <class 'pathlib.PosixPath'>, args = ('bash.py',), kwargs = {}
self = PosixPath('bash.py')

    def __new__(cls, *args, **kwargs):
        if cls is Path:
            cls = WindowsPath if os.name == 'nt' else PosixPath
        self = cls._from_parts(args, init=False)
        if not self._flavour.is_supported:
            raise NotImplementedError("cannot instantiate %r on your system"
>                                     % (cls.__name__,))
E           NotImplementedError: cannot instantiate 'PosixPath' on your system

C:\Python34\lib\site-packages\pathlib-1.0.1-py3.4.egg\pathlib.py:939: NotImpleme
ntedError
__________________ TestGetRules.test_get[conf_rules1-rules1] __________________

self = <tests.test_main.TestGetRules object at 0x032BAB50>
monkeypatch = <_pytest.monkeypatch.monkeypatch object at 0x03275A30>
glob = <MagicMock name='glob' id='53194576'>, conf_rules = ['bash']
rules = ['bash', 'bash']

    @pytest.mark.parametrize('conf_rules, rules', [
        (conf.DEFAULT_RULES, ['bash', 'lisp', 'bash', 'lisp']),
        (types.RulesNamesList(['bash']), ['bash', 'bash'])])
    def test_get(self, monkeypatch, glob, conf_rules, rules):
>       glob.return_value = [PosixPath('bash.py'), PosixPath('lisp.py')]

tests\test_main.py:35:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <class 'pathlib.PosixPath'>, args = ('bash.py',), kwargs = {}
self = PosixPath('bash.py')

    def __new__(cls, *args, **kwargs):
        if cls is Path:
            cls = WindowsPath if os.name == 'nt' else PosixPath
        self = cls._from_parts(args, init=False)
        if not self._flavour.is_supported:
            raise NotImplementedError("cannot instantiate %r on your system"
>                                     % (cls.__name__,))
E           NotImplementedError: cannot instantiate 'PosixPath' on your system

C:\Python34\lib\site-packages\pathlib-1.0.1-py3.4.egg\pathlib.py:939: NotImpleme
ntedError
______________________________ test_side_effect _______________________________

ssh_error = ('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!  ...own_hosts', <function ssh_e
rror.<locals>.reset at 0x033F16F0>, <function ssh_error.<locals>.known_hosts at
0x033F1198>)

    def test_side_effect(ssh_error):
        errormsg, path, reset, known_hosts = ssh_error
        command = Command('ssh user@host', stderr=errormsg)
        side_effect(command, None)
        expected = ['123.234.567.890 asdjkasjdakjsd\n', '111.222.333.444 qwepoiw
qepoiss\n']
>       assert known_hosts(path) == expected
E       assert ['123.234.567...oiwqepoiss\n'] == ['123.234.567....oiwqepoiss\n']

E         At index 1 diff: '98.765.432.321 ejioweojwejrosj\n' != '111.222.333.44
4 qwepoiwqepoiss\n'
E         Left contains more items, first extra item: '111.222.333.444 qwepoiwqe
poiss\n'
E         Use -v to get the full diff

tests\rules\test_ssh_known_host.py:61: AssertionError
=============== 4 failed, 122 passed, 2 skipped in 0.56 seconds ===============

C:\code\thefuck>
===============================================================失败===================================
_______________________________测试负载规则________________________________
嘲弄者=
def测试加载规则(模拟程序):
匹配=对象()
获取新命令=对象()
加载\u源=mocker.patch(
'thefuck.main.load_source',
返回值=模拟(匹配=匹配,
get_new_命令=get_new_命令,
按默认值启用\u=真,
优先权=900)
assert main.load_规则(路径('/rules/bash.py'))\
==规则('bash',match,get_new_命令,优先级=900)
>用('bash','/rules/bash.py')加载\u source.assert\u调用\u once\u
tests\test\u main.py:20:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Python34\lib\unittest\mock.py:782:in assert\u用
返回self.assert_调用_并带有(*args,**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_模拟自我=
args=('bash','/rules/bash.py'),kwargs={}
预期=(('bash','/rules/bash.py'),{})
_错误消息=
实际值=调用('bash','\\rules\\bash.py'),原因=无
使用(_mock_self,*args,**kwargs)调用def assert_:
“”“断言使用指定的参数调用了模拟。
如果传入的参数和关键字参数不正确,则引发AssertionError
与上次对模拟对象的调用不同
self=\u mock\u self
如果self.call_args为无:
预期=自。\格式\模拟\调用\签名(args、kwargs)
raise AssertionError('预期调用:%s\n未调用“%”(预期,))
定义错误消息():
msg=self.\u格式\u模拟\u失败\u消息(args,kwargs)
返回消息
期望值=自。\调用\匹配器((args,kwargs))
实际值=自我调用匹配器(自我调用参数)
如果预期的话!=实际:
原因=如果isinstance(预期,异常)则为预期,否则为无
>从原因引发断言错误(_error_message())
E AssertionError:预期调用:load_source('bash','/rules/bash.py'))
实际调用:加载\u源('bash','\\rules\\bash.py')
C:\Python34\lib\unittest\mock.py:771:AssertionError
__________________TestGetRules.test_get[conf_rules0-rules0]__________________
自我=
monkeypatch=
glob=,conf_rules=[]
规则=['bash','lisp','bash','lisp']
@parametrize('conf_rules,rules'[
(conf.DEFAULT_规则,['bash','lisp','bash','lisp']),
(types.rulesNameList(['bash']),['bash',bash']))
def test_get(self、monkeypatch、glob、conf_规则、规则):
>glob.return_value=[PosixPath('bash.py'),PosixPath('lisp.py')]
tests\test\u main.py:35:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls=,args=('bash.py',),kwargs={}
self=PosixPath('bash.py')
定义(cls,*ARG,**kwargs):
如果cls是路径:
如果os.name='nt'else PosixPath,则cls=WindowsPath
self=cls.\u来自零件(args,init=False)
如果不支持self.\u flavor
raise NOTEImplementedError(“无法在系统上实例化%r”
>%(cls.\uuuuuu name\uuuuuuuu,))
E NotImplementedError:无法在系统上实例化“PosixPath”
C:\Python34\lib\site packages\pathlib-1.0.1-py3.4.egg\pathlib.py:939:NotImpleme
内德罗
__________________TestGetRules.test_get[conf_rules1-rules1]__________________
自我=
monkeypatch=
glob=,conf_rules=['bash']
规则=['bash','bash']
@parametrize('conf_rules,rules'[
(conf.DEFAULT_规则,['bash','lisp','bash','lisp']),
(types.rulesNameList(['bash']),['bash',bash']))
def test_get(self、monkeypatch、glob、conf_规则、规则):
>glob.return_value=[PosixPath('bash.py'),PosixPath('lisp.py')]
tests\test\u main.py:35:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls=,args=('bash.py',),kwargs={}
self=PosixPath('bash.py')
定义(cls,*ARG,**kwargs):
如果cls是路径:
如果os.name='nt'else PosixPath,则cls=WindowsPath
self=cls.\u来自零件(args,init=False)
如果不支持self.\u flavor
raise NOTEImplementedError(“无法在系统上实例化%r”
>%(cls.\uuuuuu name\uuuuuuuu,))
E NotImplementedError:无法在系统上实例化“PosixPath”
C:\Python34\lib\site packages\pathlib-1.0.1-py3.4.egg\pathlib.py:939:NotImpleme
内德罗
______________________________测试副作用_______________________________
sshêU错误=(@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n@
警告:远程主机标识已更改!…own_hosts',)
def测试副作用(ssh错误):
errormsg,路径,重置,已知\u主机=ssh\u错误
command=command('sshuser@host,stderr=errormsg)
副作用(命令,无)
预期值=['123.234.567.890 asdjkasjdakjsd\n','111.222.333.444 qwepow
QEPOIS\n']
>断言已知_主机(路径)=预期
E断言['123.234.567…oiwqepoiss\n']==['123.234.567…oiwqepoiss\n']
索引1处的E差异:“98.765.432.321 ejiowejrosj\n'!=”111.222.333.44
4 QWEPOIWQEPOIS\n'
左E包含更多项,第一个额外项:'111.222.333.444 qwepoiwqe
泊松\n'
E使用-v获得完整的差异
tests\rules\test\u ssh\u known\u host.py:61:AssertionError
================4次失败,122次通过,2次在0.56秒内跳过===============
C:\code\thefuck>
我也怀疑这一点