Skip to content

Commit 9dff03b

Browse files
authored
docs: Format consistency for variables/directories/flags in unit_tests.rst (#51986)
* docs: Format consistency for variables/directories/flags in `unit_tests.rst` - Added missing backticks (``example``) to variables/flags/directories for improved readability and format consistency - Updated an incomplete paragraph * docs: Breakline adjustments for formatting fix in `unit_tests.rst` * docs: Fix whitespaces in `unit_tests.st`
1 parent 01093ed commit 9dff03b

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

contributing-docs/testing/unit_tests.rst

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ For the whole test suite you can run:
353353
354354
breeze testing core-tests --skip-db-tests
355355
356-
For selected test types (example - the tests will run for Providers/API/CLI code only:
356+
For selected test types (example - the tests will run for ``Providers/API/CLI`` code only:
357357

358358
.. code-block:: bash
359359
@@ -386,7 +386,7 @@ There are some tricky test cases that require special handling. Here are some of
386386
Parameterized tests stability
387387
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
388388

389-
The parameterized tests require stable order of parameters if they are run via xdist - because the parameterized
389+
The parameterized tests require stable order of parameters if they are run via ``xdist`` - because the parameterized
390390
tests are distributed among multiple processes and handled separately. In some cases the parameterized tests
391391
have undefined / random order (or parameters are not hashable - for example set of enums). In such cases
392392
the xdist execution of the tests will fail and you will get an error mentioning "Known Limitations of xdist".
@@ -415,7 +415,7 @@ do that:
415415
@pytest.mark.parametrize("status", sorted(ALL_STATES))
416416
def test_method(): ...
417417
418-
Similarly if your parameters are defined as result of utcnow() or other dynamic method - you should
418+
Similarly if your parameters are defined as result of ``utcnow()`` or other dynamic method - you should
419419
avoid that, or assign unique IDs for those parametrized tests. Instead of this:
420420

421421
.. code-block:: python
@@ -521,7 +521,7 @@ the test is marked as DB test:
521521
def test_from_json(self, input, request_class): ...
522522
523523
524-
Instead - this will not break collection. The TaskInstance is not initialized when the module is parsed,
524+
Instead - this will not break collection. The ``TaskInstance`` is not initialized when the module is parsed,
525525
it will only be initialized when the test gets executed because we moved initialization of it from
526526
top level / parametrize to inside the test:
527527

@@ -576,7 +576,7 @@ top level / parametrize to inside the test:
576576
577577
Sometimes it is difficult to rewrite the tests, so you might add conditional handling and mock out some
578578
database-bound methods or objects to avoid hitting the database during test collection. The code below
579-
will hit the Database while parsing the tests, because this is what Variable.setdefault does when
579+
will hit the Database while parsing the tests, because this is what ``Variable.setdefault`` does when
580580
parametrize specification is being parsed - even if test is marked as DB test.
581581

582582

@@ -617,7 +617,7 @@ parametrize specification is being parsed - even if test is marked as DB test.
617617
def test_rendered_task_detail_env_secret(patch_app, admin_client, request, env, expected): ...
618618
619619
620-
You can make the code conditional and mock out the Variable to avoid hitting the database.
620+
You can make the code conditional and mock out the ``Variable`` to avoid hitting the database.
621621

622622

623623
.. code-block:: python
@@ -724,29 +724,29 @@ this in two clicks.
724724

725725
1. Add Breeze as an "External Tool":
726726

727-
a. From the settings menu, navigate to Tools > External Tools
728-
b. Click the little plus symbol to open the "Create Tool" popup and fill it out:
727+
a. From the settings menu, navigate to ``Tools > External Tools``
728+
b. Click the little plus symbol to open the ``Create Tool`` popup and fill it out:
729729

730730
.. image:: images/pycharm/pycharm_create_tool.png
731731
:align: center
732732
:alt: Installing Python extension
733733

734734
2. Add the tool to the context menu:
735735

736-
a. From the settings menu, navigate to Appearance & Behavior > Menus & Toolbars > Project View Popup Menu
737-
b. Click on the list of entries where you would like it to be added. Right above or below "Project View Popup Menu Run Group" may be a good choice, you can drag and drop this list to rearrange the placement later as desired.
736+
a. From the settings menu, navigate to ``Appearance & Behavior > Menus & Toolbars > Project View Popup Menu``
737+
b. Click on the list of entries where you would like it to be added. Right above or below ``Project View Popup Menu Run Group`` may be a good choice, you can drag and drop this list to rearrange the placement later as desired.
738738
c. Click the little plus at the top of the popup window
739-
d. Find your "External Tool" in the new "Choose Actions to Add" popup and click OK. If you followed the image above, it will be at External Tools > External Tools > Breeze
739+
d. Find your ``External Tool`` in the new ``Choose Actions to Add`` popup and click OK. If you followed the image above, it will be at ``External Tools > External Tools > Breeze``
740740

741741
**Note:** That only adds the option to that one menu. If you would like to add it to the context menu
742742
when right-clicking on a tab at the top of the editor, for example, follow the steps above again
743-
and place it in the "Editor Tab Popup Menu"
743+
and place it in the ``Editor Tab Popup Menu``
744744

745745
.. image:: images/pycharm/pycharm_add_to_context.png
746746
:align: center
747747
:alt: Installing Python extension
748748

749-
3. To run tests in Breeze, right click on the file or directory in the Project View and click Breeze.
749+
3. To run tests in Breeze, right click on the file or directory in the ``Project View`` and click Breeze.
750750

751751

752752
Running Unit Tests from Visual Studio Code
@@ -864,8 +864,8 @@ Once you enter the container, you might run regular pytest commands. For example
864864
Running Tests using Breeze from the Host
865865
........................................
866866

867-
If you wish to only run tests and not to drop into the shell, apply the
868-
``tests`` command. You can add extra targets and pytest flags after the ``tests`` command. Note that
867+
If you wish to only run tests and not to drop into the shell, apply the ``tests`` command.
868+
You can add extra targets and pytest flags after the ``tests`` command. Note that
869869
often you want to run the tests with a clean/reset db, so usually you want to add ``--db-reset`` flag
870870
to breeze command. The Breeze image usually will have all the dependencies needed and it
871871
will ask you to rebuild the image if it is needed and some new dependencies should be installed.
@@ -931,17 +931,16 @@ Running full Airflow unit test suite in parallel
931931
................................................
932932

933933
If you run ``breeze testing core-tests --run-in-parallel`` or
934-
``breeze testing providers-tests --run-in-parallel`` tests run in parallel
935-
on your development machine - maxing out the number of parallel runs at the number of cores you
936-
have available in your Docker engine.
934+
``breeze testing providers-tests --run-in-parallel``, tests are executed in parallel
935+
on your development machine, using as many cores as are available to the Docker engine.
937936

938-
In case you do not have enough memory available to your Docker (8 GB), the ``Integration``. ``Provider``
939-
and ``Core`` test type are executed sequentially with cleaning the docker setup in-between. This
940-
allows to print
937+
If your Docker environment has limited memory (less than 8 GB), then ``Integration``, ``Provider``,
938+
and ``Core`` tests are run sequentially, with the Docker setup cleaned between test runs
939+
to minimize memory usage.
941940

942-
This allows for massive speedup in full test execution. On 8 CPU machine with 16 cores and 64 GB memory
943-
and fast SSD disk, the whole suite of tests completes in about 5 minutes (!). Same suite of tests takes
944-
more than 30 minutes on the same machine when tests are run sequentially.
941+
This approach allows for a massive speedup in full test execution. On a machine with 8 CPUs
942+
(16 cores), 64 GB of RAM, and a fast SSD, the full suite of tests can complete in about
943+
5 minutes (!) — compared to more than 30 minutes when run sequentially.
945944

946945
.. note::
947946

@@ -952,7 +951,7 @@ more than 30 minutes on the same machine when tests are run sequentially.
952951
in the ``Docker for Mac`` documentation on how to do it.
953952

954953
You can also limit the parallelism by specifying the maximum number of parallel jobs via
955-
MAX_PARALLEL_TEST_JOBS variable. If you set it to "1", all the test types will be run sequentially.
954+
``MAX_PARALLEL_TEST_JOBS`` variable. If you set it to "1", all the test types will be run sequentially.
956955

957956
.. code-block:: bash
958957
@@ -1254,7 +1253,7 @@ running the tests from there, after manually downgrading the dependencies:
12541253
cd airflow-core
12551254
uv sync --resolution lowest-direct
12561255
1257-
or run --force-lowest-dependencies switch directly from the breeze command line:
1256+
or run ``--force-lowest-dependencies`` switch directly from the breeze command line:
12581257

12591258
.. code-block:: bash
12601259
@@ -1298,7 +1297,7 @@ manually downgrading dependencies for the provider and running the tests after t
12981297
uv sync --resolution lowest-direct
12991298
13001299
1301-
or run --force-lowest-dependencies switch directly from the breeze command line:
1300+
or run ``--force-lowest-dependencies`` switch directly from the breeze command line:
13021301

13031302
.. code-block:: bash
13041303
@@ -1421,7 +1420,7 @@ Enable masking secrets in tests
14211420
...............................
14221421

14231422
By default masking secrets in test disabled because it might have side effects
1424-
into the other tests which intends to check logging/stdout/stderr values
1423+
into the other tests which intends to check ``logging/stdout/stderr`` values
14251424

14261425
If you need to test masking secrets in test cases
14271426
you have to apply ``pytest.mark.enable_redact`` to the specific test case, class or module.

0 commit comments

Comments
 (0)