GithubHelp home page GithubHelp logo

nickjmiller / pytest-fixtures Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 10.0 18.84 MB

Pytest fixtures autocomplete for vscode

Home Page: https://marketplace.visualstudio.com/items?itemName=nickmillerdev.pytest-fixtures

License: MIT License

TypeScript 93.76% JavaScript 3.29% Python 2.95%
fixtures pytest python vscode-extension

pytest-fixtures's People

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-fixtures's Issues

addition pytest arguments when discover fixtures

Some time we need to add extra arguments when run "pytest --fixture" to discover fixtures from other pytest plugins. For example we have a pip packet called abcfw, we use "-p abcfw.pytest.common.bootstrap" to discover all fixtures inside the abcfw.

can you add such support such as ?

The solution is in the .vscode/settings.json we need to add the extra arguments and the plugin uses this args if exist.
{
    "pytest-fixtures.extra_arguments": [
        "-p",
        "cspfw.pytest.common.bootstrap",
    ]
}

Go-to-definition does not work for fixtures in test cases with big names

Describe the bug
If a test case:

  1. has a name larger than 64 characters
  2. and its arguments are in separate lines

the go-to-definition will only work for the first fixture.

To Reproduce
Steps to reproduce the behavior:

  1. Copy the code that exists in the bottom of this Issue
  2. Go to the test case with name test_____________in_this_test_case_the_fixtures_are_in_seperate_lines___only_the_go_to_definition_of_the_first_fixture_works_____
  3. Try to go-to-definition of the dummy_fixture_return_2
  4. Assert that go-to-definition does not work

Expected behavior
The go-to-definition should work for both of the fixtures.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: WSL2 on Windows 10
  • Version Python 3.9, Ubuntu 20.04.04 LTS, Windows 10

Please paste the output of pytest --fixtures for the affected file

------- fixtures defined from tests.test_main -------
dummy_fixture_return_1 -- tests/test_main.py:5
    no docstring available

dummy_fixture_return_2 -- tests/test_main.py:9
    no docstring available

You can find the command used by navigating to Output > pytest-fixtures, it should log out Running command /.../pytest --color no --fixtures -v /.../file.py in directory /.../Directory. You can remove partial paths.
When I click on the fixture dummy_fixture_return_2 nothing is logged.

Attached Code:

import pytest 

# Fixture definitions 
@pytest.fixture
def dummy_fixture_return_1():
    return 1

@pytest.fixture
def dummy_fixture_return_2():
    return 2

# simple function 
def plus(a,b):
    return a + b


# In test cases with a big name *and* with the *fixtures in the same line*, the go to definition works
# e.g.
def test_____________in_this_test_case_the_go_to_definition_works_for_both_of_the_fixtures_____(dummy_fixture_return_1,dummy_fixture_return_2):
    assert plus(dummy_fixture_return_1,dummy_fixture_return_2) == 3

# In test cases with a big name *and* with the fixtures in *seperate* lines, the go to definition works only for the first fixture
def test_____________in_this_test_case_the_fixtures_are_in_seperate_lines___only_the_go_to_definition_of_the_first_fixture_works_____(
    dummy_fixture_return_1,   # Go to definition for this fixture works. 
    dummy_fixture_return_2    # Go to definition for this fixture *does not* work
    ):
    assert plus(dummy_fixture_return_1,dummy_fixture_return_2) == 3

Logging Issues

In provideDefinition:
log(`Called provideDefinition: ${document.fileName}, position: ${position}`);
position is an object and isn't logged properly.

Same in provideCompletionItems

Go to definition doesn't work

If I click go to definition on the fixture it just goes to where the fixture is actually being used. Also there are logs indicating the full path to opening files is wrong:

[6/2/2022 - 1:50:15 PM] Unable to read file at path /Users/XXXX/Tests/Tests/integration/conftest.py, Error: ENOENT: no such file or directory, open '/Users/XXXX/Tests/Tests/integration/conftest.py'

The path should be: '/Users/XXXX/Tests/integration/conftest.py' Maybe this is related the issue.

There are also logs saying it found fixtures. I'm not sure what is going on here.

Maybe some settings need to be opened up so we can configure file paths ourselves. Not sure.

Fixtures don't appear for autocompletion if function parameters span multiple lines

def test_post_score_v1_batch_generates_archives_error_archives(enable_archiving_file_system, client_v5_ens_pip,
                                                               v1_endpoint, archive_dir,
                                                               lc_batch_payload_json_v1):

If I have a function definition like this, only the first line of the parameters will autocomplete fixtures. If I try to add a new fixture after 'lc_batch_payload_json_v1', no autocompletion pops up.

I think this is due to this code in suggestionProvider.ts:

            if (
                lineTextBeforePosition.includes("(") &&
                !lineTextBeforePosition.includes(")")
            ) {

AND due to how lineCanUseFixtureSuggestions works.

Also, Go To Definition isn't working for fixtures that aren't in the first line of function parameters. I believe this is because of how lineCanUseFixtureSuggestions works also.

Extension does not run for test files that don't start with `test_` or `conftest`

Describe the bug
In a project I'm working on, our test files are named like *_test.py but this extension does not appear to run on those files. I would expect the supported file name patterns to match those supported by pytest, which looks for files matching test_*.py and *_test.py during test discovery (docs).

To Reproduce
Steps to reproduce the behavior:

  1. Create a file named foo_test.py
  2. Begin defining a test function that takes the pytest built-in monkeypatch fixture (e.g. def foo_test(monk...))
  3. Observe that there is no Intellisense suggestion provided
  4. Rename the file to test_foo.py and repeat step 2 and observe Intellisense as expected

Expected behavior
I expected Intellisense and Go To Definition to work as described in both test_*.py files and *_test.py files

Screenshots
Does not work in foo_test.py
image

Works in test_foo.py
image

Desktop (please complete the following information):

  • OS: MacOS Monterey 12.5
  • Browser: N/A
  • Version: VS Code 1.70.1

Please paste the output of pytest --fixtures for the affected file

Click to expand
(pytest-fixtures) ➜  ~/code/pytest-fixtures git:(sb-test-file-names) ✗ pytest --fixtures test-fixture/test_package/foo_test.py
=============================================================================================================== test session starts ===============================================================================================================
platform darwin -- Python 3.9.1, pytest-7.1.2, pluggy-1.0.0
rootdir: /Users/stevebeal/code/pytest-fixtures
collected 1 item
cache -- .../_pytest/cacheprovider.py:510
    Return a cache object that can persist state between testing sessions.

capsys -- .../_pytest/capture.py:878
Enable text capturing of writes to sys.stdout and sys.stderr.

capsysbinary -- .../_pytest/capture.py:895
Enable bytes capturing of writes to sys.stdout and sys.stderr.

capfd -- .../_pytest/capture.py:912
Enable text capturing of writes to file descriptors 1 and 2.

capfdbinary -- .../_pytest/capture.py:929
Enable bytes capturing of writes to file descriptors 1 and 2.

doctest_namespace [session scope] -- .../_pytest/doctest.py:731
Fixture that returns a :py:class:dict that will be injected into the
namespace of doctests.

pytestconfig [session scope] -- .../_pytest/fixtures.py:1334
Session-scoped fixture that returns the session's :class:pytest.Config
object.

record_property -- .../_pytest/junitxml.py:282
Add extra properties to the calling test.

record_xml_attribute -- .../_pytest/junitxml.py:305
Add extra xml attributes to the tag for the calling test.

record_testsuite_property [session scope] -- .../_pytest/junitxml.py:343
Record a new <property> tag as child of the root <testsuite>.

tmpdir_factory [session scope] -- .../_pytest/legacypath.py:295
Return a :class:pytest.TempdirFactory instance for the test session.

tmpdir -- .../_pytest/legacypath.py:302
Return a temporary directory path object which is unique to each test
function invocation, created as a sub directory of the base temporary
directory.

caplog -- .../_pytest/logging.py:487
Access and control log capturing.

monkeypatch -- .../_pytest/monkeypatch.py:29
A convenient fixture for monkey-patching.

recwarn -- .../_pytest/recwarn.py:29
Return a :class:WarningsRecorder instance that records all warnings emitted by test functions.

tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:184
Return a :class:pytest.TempPathFactory instance for the test session.

tmp_path -- .../_pytest/tmpdir.py:199
Return a temporary directory path object which is unique to each test
function invocation, created as a sub directory of the base temporary
directory.

--------------------------------------------------------------------------------------------------------- fixtures defined from conftest ----------------------------------------------------------------------------------------------------------
another_example -- test-fixture/conftest.py:10
Another example fixture

async_fixture -- test-fixture/conftest.py:14
Example async fixture

example_fixture -- test-fixture/conftest.py:5
Example fixture

--------------------------------------------------------------------------------------------------- fixtures defined from test_package.conftest ---------------------------------------------------------------------------------------------------
example_fixture -- test-fixture/test_package/conftest.py:4
Example fixture 2

============================================================================================================== no tests ran in 0.00s ==============================================================================================================

In a multi-folder project, pytest-fixtures runs pytest with the first folder as CWD, not the folder where the tests are

In a multi-folder project, pytest-fixtures runs pytest with the first folder as CWD, not the folder under which the current file resides.

Expected behavior
Expected pytest-fixtures to run with the folder where the file resides as the CWD.

Logs

[05/02/2023 - 13:46:13] Active file changed; Loading fixtures for /Users/tuure/work/repo/server/tests/web_api/a_route.py
[05/02/2023 - 13:46:13] Running command /Users/tuure/work/repo/server/bin/run-pytest-in-compose.sh -m pytest --color no --fixtures -v /Users/tuure/work/repo/server/tests/web_api/a_route.py in directory /Users/tuure/work/repo/frontend

Note that the command gets run in directory /Users/tuure/work/repo/frontend, not /Users/tuure/work/repo/server.

After changing the run-pytest-in-compose.sh so that it switches to /Users/tuure/work/repo/server before running docker-compose, I get the fixture suggestions in test function parameter list.

Desktop (please complete the following information):

  • OS: Mac OS

Navigation to fixture definition

Hi, I would like to add some contribution to this extension.

I think we can deduct from pytest output the location of the fixtures.

For example, from a folder structure like this (each conftest defines some fixtures, and the test file defines them too):

.
├── conftest.py
└── test_package
    ├── conftest.py
    ├── __init__.py
    └── test_example.py

if I run the command pytest --fixtures test_package/test_example.py I get (apart than the standard fixtures):

-------------------------------------------------------------------------------------- fixtures defined from conftest ---------------------------------------------------------------------------------------
another_example
    Another example fixture

example_fixture
    Example fixture


-------------------------------------------------------------------------------- fixtures defined from test_package.conftest --------------------------------------------------------------------------------
example_fixture
    Example fixture 2


------------------------------------------------------------------------------ fixtures defined from test_package.test_example ------------------------------------------------------------------------------
local_fixture
    Local fixture


===============================================================================

The title of each section (fixtures defined from ...) coud be used to detect the path to the file defining the fixture, and maybe to find the definition line too.

What do you think? I could start working on it :)

Doesn't work with pytest-describe

Thank you for making this!

Describe the bug
The extension is working great on regular tests, but does not seem to support pytest-describe, which allows you to group tests together in "describe" blocks.

To Reproduce
Install pytest-describe, copy in their example test, and try adding some fixtures. Fixture autocomplete does not show up and you can't jump to fixture definitions

Performance issue

After adding this extension to a multi root workspace, each test file save take 30s and shows the "File Saving..." popup

is it searching for fixtures on save?

A Suggestion to Improve UX

First of all: @nickjmiller thank you so much for your contribution, which is a huge help to me!

May I suggest to consider using the python.testing.cwd setting parameter?

I found in the Output that pytest-fixtures is running on the VS Code project's working directory, which appears to be the same approach the Python extension is taking in order to discover tests - which does not work for the folder structure of my project, so I am using its python.testing.cwd setting in order to point to my test root directory.

pytest-fixtures could provide the option to use python.testing.cwd as well.
Should you want to introduce such an option, I believe it needs to be false by default in order not to confuse existing installations.

Instead, should this suggestion not work with your product vision, the docs could suggest that providing pytest's --rootdir option in pytest-fixtures.extraArguments can help. (For me, this would duplicate settings, as --rootdir and python.testing.cwd would effectively be pointing to the very same location.)

Unable to read file at path error and no fixture definition

Describe the bug
In VS Code cannot get the fixture definitions/documentation. The output log returns errors about files not found, eg:

Unable to read file at path /Users/andre.ricardo/code/fixtures-playground/.../_pytest/cacheprovider.py, Error: ENOENT: no such file or directory, open '/Users/andre.ricardo/code/fixtures-playground/.../_pytest/cacheprovider.py'

To Reproduce
Steps to reproduce the behavior:

  1. Create a fixture and a test
import pytest

@pytest.fixture
def my_fixture():
    """Returns True"""
    return True
def test_true(my_fixture):
    assert my_fixture

If it's any help, I've created a repo (https://github.com/andrericardo/fixtures-playground) with just one fixture and a test to replicate the issue.
2. Move the mouse over my_fixture in VS Code and if I understood how this extension should work, it should display the "Returns true" documentation?

Expected behavior
Expected VS Code to show the documentation for my_fixture

Screenshots

Sample code:
image

Error in VS Code Output > pytest-fixtures

image

Desktop (please complete the following information):

  • OS: macOS, ProductVersion: 12.4, BuildVersion: 21F79
  • VS Code: Version: 1.69.2 (Universal)
  • pytest-fixtures version: v0.2.2

Please paste the output of pytest --fixtures for the affected file

/Users/andre.ricardo/.pyenv/versions/3.10.4/bin/python -m pytest --color no --fixtures -v /Users/andre.ricardo/code/fixtures-playground/src/tests/unit/test_example.py
============================= test session starts ==============================
platform darwin -- Python 3.10.4, pytest-7.1.0, pluggy-1.0.0 -- /Users/andre.ricardo/.pyenv/versions/3.10.4/bin/python
cachedir: .pytest_cache
rootdir: /Users/andre.ricardo/code/fixtures-playground
plugins: time-machine-2.6.0, recording-0.12.0, aiohttp-0.3.0, icdiff-0.5
collected 1 item
cache -- .../_pytest/cacheprovider.py:510
    Return a cache object that can persist state between testing sessions.
    
    cache.get(key, default)
    cache.set(key, value)
    
    Keys must be ``/`` separated strings, where the first part is usually the
    name of your plugin or application to avoid clashes with other cache users.
    
    Values can be any object handled by the json stdlib module.

capsys -- .../_pytest/capture.py:878
    Enable text capturing of writes to ``sys.stdout`` and ``sys.stderr``.
    
    The captured output is made available via ``capsys.readouterr()`` method
    calls, which return a ``(out, err)`` namedtuple.
    ``out`` and ``err`` will be ``text`` objects.

capsysbinary -- .../_pytest/capture.py:895
    Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
    
    The captured output is made available via ``capsysbinary.readouterr()``
    method calls, which return a ``(out, err)`` namedtuple.
    ``out`` and ``err`` will be ``bytes`` objects.

capfd -- .../_pytest/capture.py:912
    Enable text capturing of writes to file descriptors ``1`` and ``2``.
    
    The captured output is made available via ``capfd.readouterr()`` method
    calls, which return a ``(out, err)`` namedtuple.
    ``out`` and ``err`` will be ``text`` objects.

capfdbinary -- .../_pytest/capture.py:929
    Enable bytes capturing of writes to file descriptors ``1`` and ``2``.
    
    The captured output is made available via ``capfd.readouterr()`` method
    calls, which return a ``(out, err)`` namedtuple.
    ``out`` and ``err`` will be ``byte`` objects.

doctest_namespace [session scope] -- .../_pytest/doctest.py:731
    Fixture that returns a :py:class:`dict` that will be injected into the
    namespace of doctests.

pytestconfig [session scope] -- .../_pytest/fixtures.py:1334
    Session-scoped fixture that returns the session's :class:`pytest.Config`
    object.
    
    Example::
    
        def test_foo(pytestconfig):
            if pytestconfig.getoption("verbose") > 0:
                ...

record_property -- .../_pytest/junitxml.py:282
    Add extra properties to the calling test.
    
    User properties become part of the test report and are available to the
    configured reporters, like JUnit XML.
    
    The fixture is callable with ``name, value``. The value is automatically
    XML-encoded.
    
    Example::
    
        def test_function(record_property):
            record_property("example_key", 1)

record_xml_attribute -- .../_pytest/junitxml.py:305
    Add extra xml attributes to the tag for the calling test.
    
    The fixture is callable with ``name, value``. The value is
    automatically XML-encoded.

record_testsuite_property [session scope] -- .../_pytest/junitxml.py:343
    Record a new ``<property>`` tag as child of the root ``<testsuite>``.
    
    This is suitable to writing global information regarding the entire test
    suite, and is compatible with ``xunit2`` JUnit family.
    
    This is a ``session``-scoped fixture which is called with ``(name, value)``. Example:
    
    .. code-block:: python
    
        def test_foo(record_testsuite_property):
            record_testsuite_property("ARCH", "PPC")
            record_testsuite_property("STORAGE_TYPE", "CEPH")
    
    ``name`` must be a string, ``value`` will be converted to a string and properly xml-escaped.
    
    .. warning::
    
        Currently this fixture **does not work** with the
        `pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See
        :issue:`7767` for details.

tmpdir_factory [session scope] -- .../_pytest/legacypath.py:295
    Return a :class:`pytest.TempdirFactory` instance for the test session.

tmpdir -- .../_pytest/legacypath.py:302
    Return a temporary directory path object which is unique to each test
    function invocation, created as a sub directory of the base temporary
    directory.
    
    By default, a new base temporary directory is created each test session,
    and old bases are removed after 3 sessions, to aid in debugging. If
    ``--basetemp`` is used then it is cleared each session. See :ref:`base
    temporary directory`.
    
    The returned object is a `legacy_path`_ object.
    
    .. _legacy_path: https://py.readthedocs.io/en/latest/path.html

caplog -- .../_pytest/logging.py:487
    Access and control log capturing.
    
    Captured logs are available through the following properties/methods::
    
    * caplog.messages        -> list of format-interpolated log messages
    * caplog.text            -> string containing formatted log output
    * caplog.records         -> list of logging.LogRecord instances
    * caplog.record_tuples   -> list of (logger_name, level, message) tuples
    * caplog.clear()         -> clear captured records and formatted log output string

monkeypatch -- .../_pytest/monkeypatch.py:29
    A convenient fixture for monkey-patching.
    
    The fixture provides these methods to modify objects, dictionaries or
    os.environ::
    
        monkeypatch.setattr(obj, name, value, raising=True)
        monkeypatch.delattr(obj, name, raising=True)
        monkeypatch.setitem(mapping, name, value)
        monkeypatch.delitem(obj, name, raising=True)
        monkeypatch.setenv(name, value, prepend=None)
        monkeypatch.delenv(name, raising=True)
        monkeypatch.syspath_prepend(path)
        monkeypatch.chdir(path)
    
    All modifications will be undone after the requesting test function or
    fixture has finished. The ``raising`` parameter determines if a KeyError
    or AttributeError will be raised if the set/deletion operation has no target.

recwarn -- .../_pytest/recwarn.py:29
    Return a :class:`WarningsRecorder` instance that records all warnings emitted by test functions.
    
    See https://docs.python.org/library/how-to/capture-warnings.html for information
    on warning categories.

tmp_path_factory [session scope] -- .../_pytest/tmpdir.py:183
    Return a :class:`pytest.TempPathFactory` instance for the test session.

tmp_path -- .../_pytest/tmpdir.py:198
    Return a temporary directory path object which is unique to each test
    function invocation, created as a sub directory of the base temporary
    directory.
    
    By default, a new base temporary directory is created each test session,
    and old bases are removed after 3 sessions, to aid in debugging. If
    ``--basetemp`` is used then it is cleared each session. See :ref:`base
    temporary directory`.
    
    The returned object is a :class:`pathlib.Path` object.


----------------- fixtures defined from aiohttp.pytest_plugin ------------------
fast -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:115
    --fast config option

loop_debug -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:121
    --enable-loop-debug config option

loop -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:226
    Return an instance of the event loop.

proactor_loop -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:238
    no docstring available

unused_port -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:252
    no docstring available

aiohttp_unused_port -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:262
    Return a port that is unused on the current host.

aiohttp_server -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:268
    Factory to create a TestServer instance, given an app.
    
    aiohttp_server(app, **kwargs)

test_server -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:291
    no docstring available

aiohttp_raw_server -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:301
    Factory to create a RawTestServer instance, given a web handler.
    
    aiohttp_raw_server(handler, **kwargs)

raw_test_server -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:324
    no docstring available

aiohttp_client -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:336
    Factory to create a TestClient instance.
    
    aiohttp_client(app, **kwargs)
    aiohttp_client(server, **kwargs)
    aiohttp_client(raw_server, **kwargs)

test_client -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/aiohttp/pytest_plugin.py:385
    no docstring available


---------------- fixtures defined from pytest_recording.plugin -----------------
vcr -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/pytest_recording/plugin.py:120
    Install a cassette if a test is marked with `pytest.mark.vcr`.

vcr_cassette_dir [module scope] -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/pytest_recording/plugin.py:143
    Each test module has its own cassettes directory to avoid name collisions.
    
    For example each test module could have test function with the same names:
      - test_users.py:test_create
      - test_profiles.py:test_create

default_cassette_name -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/pytest_recording/plugin.py:155
    no docstring available

record_mode [session scope] -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/pytest_recording/plugin.py:68
    When recording is disabled the VCR recording mode should be "none" to prevent network access.

disable_recording [session scope] -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/pytest_recording/plugin.py:74
    Disable VCR.py integration.

vcr_config -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/pytest_recording/plugin.py:80
    A shareable configuration for VCR.use_cassette call.

vcr_markers -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/pytest_recording/plugin.py:86
    All markers applied to the certain test together with cassette names associated with each marker.

block_network -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/pytest_recording/plugin.py:92
    Block network access in tests except for "none" VCR recording mode.


---------------------- fixtures defined from time_machine ----------------------
time_machine -- ../../.pyenv/versions/3.10.4/lib/python3.10/site-packages/time_machine/__init__.py:427
    no docstring available


------------------------ fixtures defined from conftest ------------------------
my_fixture -- src/tests/unit/conftest.py:5
    Returns True


============================ no tests ran in 0.01s =============================

Can't make it work

Hello. I'm not sure I have rights to create an issue in this case. I apologize if i shouldn't do it.
I think this extension may be very useful for me, but I can't make it work. May be I do something wrong and someone could explain me what exactly.

  1. I installed the extension
    image
  2. got path of pytest
    image
  3. set "python.testing.pytestPath" in settings.json
    image

But when I start typing fixture name I see no reaction (on screenshot below I'm trying it in root_project_folder/tests/conftest.py):
image

Don`t work with @pytest_asyncio.fixture

If i use any other name instead @pytest.fixture, extension will not work.
Fix it, please. <3

Maybe, make sense to add list with available names in setting.json. Because we have some extension like lazy_fixture etc.

Doesn't run --fixture command

Hello,

I've installed pytest-fixtures to MS VS Code but it doesn't work.
Looks like it doesn't run the shell command.

pytest-fixtures output is:
[2/14/2023 - 2:00:16 PM] Called provideCompletionItems: /opt/web/by_seq_tests.py, position: {"line":5,"character":56 [2/14/2023 - 2:00:16 PM] GetSuggestions: /opt/web/by_seq_tests.py [2/14/2023 - 2:00:17 PM] Called provideDefinition: /opt/web/by_seq_tests.py, position: {"line":5,"character":49}

I've try to specify absolute path python.testing.pytestPath and set python.testing.pytestEnable: true in workspace and user settings but have no effect.

Log(Extension Host):
2023-02-16 16:21:09.316 [error] TypeError: Cannot read properties of undefined (reading 'find') at e.PytestFixtureProvider.getFixtures (/home/ololo/.vscode/extensions/nickmillerdev.pytest-fixtures-0.2.8/dist/extension.js:1:13455) at /home/ololo/.vscode/extensions/nickmillerdev.pytest-fixtures-0.2.8/dist/extension.js:1:13329

Pytest extra arguments option winds up duplicating the base arguments

Describe the bug
A bug was introduced in commit 97d00b0 that duplicates args.

To Reproduce
Navigate to some python source and look at the output tab dialed in to pytest-fixtures and look for the Running command trace

Running command <selected_python_interpreter> -m pytest --color no --fixtures -v <my_test_module.py> --color no --fixtures -v <my_test_module.py>

Expected behavior
Only one base argument set should be present

Support Named Configurations

This is a lovely extension so right off the bat, thank you for developing this. It's great to be able to harness those static decorators pytest utilizes to put into effect fixture navigation which by itself the vscode python extensions are unable to do since a fixture usage is just a formal parameter at the end of the day.

I have a feature request to support named configurations I'd like you to consider. I work on a large codebase and we actually leverage multi definition backings of a given fixture, albeit only one is available at a given time.

To be concrete consider the following set of files

# test_module_foo.py

def test_case_bar(my_foo_fixture):
#test_project_baz/plugin_x.py
@pytest.fixture
def my_foo_fixture():
    return "x"
#test_project_baz/plugin_y.py
@pytest.fixture
def my_foo_fixture():
    return "y"

I'd like to be able to toggle between test_project_baz_config_x in one code navigation session vs test_project_baz_config_y in another. Think about the built in Run and Debug sidebar and how we can specify debug configurations tailored to a given test project by name from its pulldown menu.

image

doing something analogous for the plugin selections would be absolutely a supreme feature.

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.