kaste / PyTest

pytest runner and view annotator for sublime text
21 stars 6 forks source link

Doesn't work in Windows 10 for me #10

Closed ivavid closed 6 years ago

ivavid commented 6 years ago

The test program (from the pytest.org example):

def inc(x):
    return x + 1

def test_answer():
    assert inc(3) == 5

After running PyTest in Sublime Text 3 the output panel displays the following:

[WinError 2] The system cannot find the file specified
[cmd: ['python -m py.test', '--tb=auto', '-l', 'C:\\cygwin64\\home\\User1\\dir1\\test\\test_playground.py::test_answer', '--junit-xml=C:\\Users\\User1\\AppData\\Local\\Sublime Text 3\\Cache\\PyTest\\last-run.xml']]
[dir: C:\cygwin64\home\User1\dir1\test]
[path: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\User1\AppData\Local\Microsoft\WindowsApps;c:\cygwin64\bin;C:\Python27]

Running the command from the command line produces:

c:\cygwin64\home\User1\dir1\test>python -m py.test --tb=auto -l C:\cygwin64\home\User1\dir1\test\test_playground.py --junit-xml=C:\Users\User1\AppData\Local\Sublime Text 3\Cache\PyTest\last-run.xml
============================= test session starts =============================
platform win32 -- Python 2.7.15, pytest-3.7.1, py-1.5.4, pluggy-0.7.1
rootdir: c:\cygwin64\home\User1\dir1\test, inifile:

--------- generated xml file: C:\Users\User1\AppData\Local\Sublime ----------
======================== no tests ran in 0.01 seconds =========================
ERROR: file not found: Text

Note the last two lines

Enclosing the --junit-xml parameter in double quotation marks produces the expected result:

c:\cygwin64\home\User1\dir1\test>python -m py.test --tb=auto -l C:\cygwin64\home\User1\dir1\test\test_playground.py --junit-xml="C:\Users\User1\AppData\Local\Sublime Text 3\Cache\PyTest\last-run.xml"
============================= test session starts =============================
platform win32 -- Python 2.7.15, pytest-3.7.1, py-1.5.4, pluggy-0.7.1
rootdir: c:\cygwin64\home\User1\dir1\test, inifile:
collected 1 item

test_playground.py F                                                     [100%]

================================== FAILURES ===================================
_________________________________ test_answer _________________________________

    def test_answer():
>       assert inc(3) == 5
E       assert 4 == 5
E        +  where 4 = inc(3)

test_playground.py:6: AssertionError
 generated xml file: C:\Users\User1\AppData\Local\Sublime Text 3\Cache\PyTest\last-run.xml
========================== 1 failed in 0.05 seconds ===========================

Is the problem I'm having caused by the package or could it be my setup?

kaste commented 6 years ago

Hi!

Unfortunately something like 'python -m py.test' is not supported, the setting pytest must point to a real executable t.i. absolute path plus .exe extension unless py.test is globally available via PATH.

Maybe we should add that functionality.

EDIT: The .exe extension is not necessary.

kaste commented 6 years ago

Closing now due to age but would take a PR.