Code Monkey home page Code Monkey logo

pytest's People

Contributors

jgirardet avatar jodylent avatar kaste avatar pykong avatar sbibauw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pytest's Issues

Inline Annotations not showing

Good evening, dear @kaste.

First, congrats for this amazing package!

I am using Sublime Text 3211 on macOS Catalina and the annotations are not showing when saving the test. The status bar color is changing correctly, and the screen seems blink when I save the file (I think it's visible in the gif I posted). I tried with different files, directories and projects, and it didn't work. The package options seems to be ok and just the defaults are active, so "show_phantoms": true. Any idea about what I can do?

Thank you in advance,

Gustavo

screencapture

cannot find settings file + python version mismatch

Hi!
I know it's a stupid question, but I cannot find the plugin settings file into my sublime text application support folder
~/Library/Application Support/Sublime Text 3/Packages

Am I supposed to create it myself? Is it stored somewhere else?
It would be maybe good idea to mention its position into the README

btw, my issue is that the standard python used for my builds in ST3 is brew python3 located
/usr/local/bin/python3

instead pytest is executed from python2.

How can I match them?

Doesn't work in Windows 10 for me

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?

Errors parsing theme

Hi,

So this is happening all of a sudden, and its messing up all the icons throughout sublimetext

Run /opt/python/3.10/bin/python3 -m pytest -sv test
Errors parsing theme:
  "class" is required in Packages/User/Adaptive.sublime-theme:66:2
Errors parsing theme:
  "class" is required in Packages/User/Adaptive.sublime-theme:66:2
glGetError: GL_INVALID_OPERATION
Run /opt/python/3.10/bin/python3 -m pytest -sv test
Errors parsing theme:
  "class" is required in Packages/User/Adaptive.sublime-theme:66:2
Errors parsing theme:
  "class" is required in Packages/User/Adaptive.sublime-theme:66:2
Errors parsing theme:
  "class" is required in Packages/User/Adaptive.sublime-theme:66:2
reloading settings Packages/User/Preferences.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
font face "Times" could not be found, defaulting to "Monospace"

File: Adaptive.sublime-theme

[
	{
		"class": "status_bar",
		"layer0.tint":
		[
			8,
			131,
			8
		],
		"settings":
		[
			"pytest_is_green"
		]
	},
	{
		"class": "label_control",
		"color":
		[
			19,
			21,
			32
		],
		"parents":
		[
			{
				"class": "status_bar"
			}
		],
		"settings":
		[
			"pytest_is_green"
		]
	},
	{
		"class": "status_bar",
		"layer0.tint":
		[
			155,
			7,
			8
		],
		"settings":
		[
			"pytest_is_red"
		]
	},
	{
		"class": "label_control",
		"color":
		[
			199,
			191,
			192
		],
		"parents":
		[
			{
				"class": "status_bar"
			}
		],
		"settings":
		[
			"pytest_is_red"
		]
	},
]

Enhancement: Create test stubs

I believe a great enhancement for this package would be a command to create test stubs.
Such would parallel a function many IDEs, like Visual Studio, provide to make the life of the lazy programmer more comfortable.

app.py

def add(a: int, b: int) -> int:
    return a + b

Will create this test file under the respective path with some test stub already in it:

/tests/test_app.py

import pytest

from ..app import add

def test_add(self):
    """Test for add."""
    raise NotImplementedError("Test for add not implemented.")

Tilde is not expanded in "pytest" setting

The tilde is not expanded in the "pytest" setting, so I should hardcode my home directory for the plugin to work ("~/.virtualenvs/${project_base_name}/Scripts/pytest.exe" does not work)

Enhancement: Provide info in status bar

What about displaying the current test status in the status bar:
Like so

[12 | 3 ] - 12 passed, 3 failed

Or even with test coverage:

[12 | 3 | 74%] - 74% test coverage

Deprecation warning

The following warning

(virtual environment)/lib/python3.6/site-packages/_pytest/junitxml.py:436
(virtual environment)/lib/python3.6/site-packages/_pytest/junitxml.py:436: PytestDeprecationWarning: The 'junit_family' default value will change to 'xunit2' in pytest 6.0.
  Add 'junit_family=legacy' to your pytest.ini file to silence this warning and make your suite compatible.
    _issue_warning_captured(deprecated.JUNIT_XML_DEFAULT_FAMILY, config.hook, 2)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
- generated xml file: ~/.config/sublime-text-3/Cache/PyTest/last-run.xml -

Is caused by the following line:

kw['cmd'] += ['--junit-xml={}'.format(get_report_file())]

The way to solve this, according to pytest:

junit_family default value change to "xunit2"

Deprecated since version 5.2.

The default value of junit_family option will change to xunit2 in pytest 6.0, given that this is the version supported by default in modern tools that manipulate this type of file.

In order to smooth the transition, pytest will issue a warning in case the --junitxml option
is given in the command line but junit_family is not explicitly configured in pytest.ini.

PytestDeprecationWarning: The 'junit_family' default value will change to 'xunit2' in pytest 6.0.
  Add 'junit_family=legacy' to your pytest.ini file to silence this warning and make your suite compatible.

In order to silence this warning, users just need to configure the junit_family option explicitly:

[pytest]
junit_family=legacy

Inline view annotation on failure not working?

I installed the plugin yesterday, and found it was great! ๐Ÿ‘ Thank you for sharing such a great plugin for sublime3, which make it much easier for me to develop in python with pytest and sublime.

But I can not figure out how to make the inline annotation feature working. I setup a project with only one test file and with the default setting of PyTest. The test run automatically on save, but do not annotate the views on failures.

Here is the screen short of my sublime.
pytest_subl_snapshot

There are some errors in the console, which I suppose to not relate to the problem:

modified
Run py.test --tb=auto -l /Users/zhangli/local_workshop/practice/pytest_subl/test_it.py
Traceback (most recent call last):
File "/Users/zhangli/Library/Application Support/Sublime Text 3/Packages/PyTest/pytest_exec.py", line 144, in parse_result
tree = etree.parse(get_report_file())
File "lxml.etree.pyx", line 3310, in lxml.etree.parse (src/lxml/lxml.etree.c:72517)
File "parser.pxi", line 1791, in lxml.etree._parseDocument (src/lxml/lxml.etree.c:105979)
File "parser.pxi", line 1817, in lxml.etree._parseDocumentFromURL (src/lxml/lxml.etree.c:106278)
File "parser.pxi", line 1721, in lxml.etree._parseDocFromFile (src/lxml/lxml.etree.c:105277)
File "parser.pxi", line 1122, in lxml.etree._BaseParser._parseDocFromFile (src/lxml/lxml.etree.c:100227)
File "parser.pxi", line 580, in lxml.etree._ParserContext._handleParseResultDoc (src/lxml/lxml.etree.c:94350)
File "parser.pxi", line 690, in lxml.etree._handleParseResult (src/lxml/lxml.etree.c:95786)
File "parser.pxi", line 618, in lxml.etree._raiseParseError (src/lxml/lxml.etree.c:94818)
OSError: Error reading file '/Users/zhangli/Library/Application Support/Sublime Text 3/Cache/PyTest/last-run.xml': failed to load external entity "/Users/zhangli/Library/Application Support/Sublime Text 3/Cache/PyTest/last-run.xml"

btw: I'm using the latest master branch of PyTest of commit c36cb0f

Enhancement: Indicate test status on function

@kaste First of all a Big Thanks for putting up this very facile plugin!

Visual Studio annotates functions with symbols indicating whether they passed a test or whether test coverage for a function exists (https://res.infoq.com/news/2017/02/Live-Unit-Testing/en/resources/live-test.gif).

I believe such visual indication would be a huge power-up for PyTest as well because of its directly linking test result on the very function being tested.

That feature could be implemented via phantoms. Alternatively, in a less favored implementation, the gutter could be used to display the symbols.

Mock-up:
g884
(symbols for pass | fail | uncovered)

Wrap long lines in the annotations/phantoms

Sometimes, I need to read the full error message. But, in the image below for example, the last line of output pannel, which begin with self, is partly covered because of no line wrap.
So , can anyone tell me how to wrap lines in output pannel?
Image

Support patching the "auto" pseudo-theme

Newer Sublime defaults to the auto theme. But we cannot patch this as we first have to resolve between which themes Sublime actually switches.

Implement this as it is the first UX.

keybinding conflict

I am using ST4 on my MBP, and installed pytest yesterday.

I found there is a conflict or unwanted behaviour. That the "cmd+s" will run pytest runner is not acceptable, since by default "cmd+s" is to save changes in files.

I would like to see there is another keybinding to trigger pytest runner, other than "cmd+s".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.