Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] add naming convention defaults for nose and pytest #8502

Merged
merged 2 commits into from
Jul 6, 2023

Conversation

mickeypash
Copy link
Contributor

Introducing a small table with a legend detailing the default naming conventions used by nose and pytest
Based on the following discussion.

Adding the tables here:

Convention unittest pytest
Ⓜ test*.py
Ⓜ test_*.py
Ⓜ *_test.py
Ⓜ *_tests.py
Ⓒ *(unittest.TestCase)
ⓜ test_*
Ⓒ Test*
ⓜ test_*
ⓕ test_*
Legend
module
Class
method
function

@RonnyPfannschmidt
Copy link
Member

https://pytest--8502.org.readthedocs.build/en/8502/how-to/nose.html?highlight=nose#unsupported-idioms-known-issues <- looks like the legend is missing

@nicoddemus
Copy link
Member

We also should rebase this after #8505 gets merged. 👍

@nicoddemus
Copy link
Member

Also not sure if it is only for me, but the symbols look really blurry:

image

@mickeypash
Copy link
Contributor Author

Thanks @RonnyPfannschmidt
I wasn't aware of this docs preview! I'll try to familiarise myself with the doc build process to avoid these issues.

  • Fix legend

@nicoddemus

The symbols look fine for me. I'm using the Brave Browser on MacOS

Screenshot 2021-03-31 at 23 57 00

@nicoddemus
Copy link
Member

The symbols look fine for me. I'm using the Brave Browser on MacOS

Thanks for the double check!

That screenshot was from Chrome on Windows.

This is from Firefox on Windows:

image

So we can disregard that, must be something with my Chrome/system. 👍

doc/en/how-to/nose.rst Outdated Show resolved Hide resolved
@mickeypash mickeypash force-pushed the patch-2 branch 2 times, most recently from 7fada98 to 36abe84 Compare April 1, 2021 22:58
@nicoddemus
Copy link
Member

We still have build failures:

/home/runner/work/pytest/pytest/doc/en/how-to/nose.rst:82: WARNING: Unknown target name: "test".
/home/runner/work/pytest/pytest/doc/en/how-to/nose.rst:84: WARNING: Unknown target name: "test".
/home/runner/work/pytest/pytest/doc/en/how-to/nose.rst:85: WARNING: Unknown target name: "test".

Seems like the Ⓜ test_*.py lines are being as target directives... 🤔

Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Ⓒ \*\(unittest.TestCase\) ✅ ✅
ⓜ test_\* ✅ ✅
Ⓒ Test\* ✅
ⓜ test_\* ✅
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps I'm missing something but isn't this the same as two lines above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted! 🙇
I looked at the source material as at this point it's a bit of a blur.
I'll need to fix the indentation somehow!
I think the original slide demonstrates it better:
Screenshot 2021-04-06 at 13 51 56

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too familiar with RST syntax, found this in the documentation Escaping Mechanism but I don't think it would serve me here. If you have any suggestions that would be great!

@mickeypash
Copy link
Contributor Author

That explains a lot!😅 I tried a number of combinations of \ to escape them but to no avail. I'll try again later.

@andrewdotn
Copy link
Contributor

This will work with non-breaking spaces:

..
   The nbsp trick is from https://stackoverflow.com/a/12145490/14558

.. |nbsp| unicode:: 0xA0
   :trim:

=============================================== ======== ======
Convention                                      nose     pytest
=============================================== ======== ======
Ⓜ test*.py                                       ✅
Ⓜ test_*.py                                      ✅       ✅
Ⓜ \*_test.py                                              ✅
Ⓜ \*_tests.py
|nbsp| |nbsp| Ⓒ \*\(unittest.TestCase\)           ✅       ✅
|nbsp| |nbsp| |nbsp| |nbsp| ⓜ test\_\*            ✅       ✅
|nbsp| |nbsp| Ⓒ Test\*                                     ✅
|nbsp| |nbsp| |nbsp| |nbsp| ⓜ test\_\*                     ✅
|nbsp| |nbsp| ⓕ test\_\*                                   ✅
=============================================== ======== ======

And that’ll even work through LaTeX too.

@Zac-HD
Copy link
Member

Zac-HD commented Jul 6, 2023

I pushed a small change, using an extra column so we can drop the symbols and legend, and using code formatting to fix some .rst issues where the patterns were interepreted as markup:

image

I'm sorry it's taken literal years to merge such a nice little PR - thanks for opening it, and for all your patience 😅

@Zac-HD Zac-HD enabled auto-merge July 6, 2023 07:13
@Zac-HD Zac-HD merged commit 901316b into pytest-dev:main Jul 6, 2023
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants