10 Matching Annotations
  1. Apr 2020
    1. Support for running tests in parallel with pytest is available through the pytest-xdist package.

      pytest-xdist provides support for parallel testing.

      1. To enable it on Windows:

      py -3 -m pip install pytest-xdist

      1. Create a file pytest.ini in your project directory and specify in it the number of CPUs to be used (e.g. 4):
        [pytest]
        addopts=-n4
        
      2. Run your tests
    2. With pytest, failed tests also appear in the Problems panel, where you can double-click on an issue to navigate directly to the test

      pytest displays failed tests also in PROBLEMS

    3. Testing in Python is disabled by default. To enable testing, use the Python: Configure Tests command on the Command Palette.

      Start testing in VS Code by using Python: Configure Tests (it automatically chooses one testing framework and disables the rest).

      Otherwise, you can configure tests manually by setting only one of the following to True:

      • python.testing.unittestEnabled
      • python.testing.pytestEnabled
      • python.testing.nosetestsEnabled
    4. python.testing.pytestArgs: Looks for any Python (.py) file whose name begins with "test_" or ends with "_test", located anywhere within the current folder and all subfolders.

      Default behaviour of test discovery by pytest framework

  2. Sep 2019
  3. Sep 2017
    1. Conventions for Python test discovery¶ pytest implements the following standard test discovery: If no arguments are specified then collection starts from testpaths (if configured) or the current directory. Alternatively, command line arguments can be used in any combination of directories, file names or node ids. recurse into directories, unless they match norecursedirs test_*.py or *_test.py files, imported by their test package name. Test prefixed test classes (without an __init__ method) test_ prefixed test functions or methods are test items For examples of how to customize your test discovery Changing standard (Python) test discovery. Within Python modules, pytest also discovers tests using the standard unittest.TestCase subclassing technique.

      how pytest finds ("discovers") tests

    1. Conventions for Python test discovery¶ pytest implements the following standard test discovery: If no arguments are specified then collection starts from testpaths (if configured) or the current directory. Alternatively, command line arguments can be used in any combination of directories, file names or node ids. Recurse into directories, unless they match norecursedirs. In those directories, search for test_*.py or *_test.py files, imported by their test package name. From those files, collect test items: test_ prefixed test functions or methods outside of class test_ prefixed test functions or methods inside Test prefixed test classes (without an __init__ method) For examples of how to customize your test discovery Changing standard (Python) test discovery. Within Python modules, pytest also discovers tests using the standard unittest.TestCase subclassing technique.

      Rules for how pytest finds ("discovers") tests.