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

Document which pytest features work with unittest #2656

Merged
merged 2 commits into from Aug 5, 2017

Conversation

nicoddemus
Copy link
Member

Fix #2626

@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.807% when pulling a5ce7d8 on nicoddemus:unittest-features into 8969bd4 on pytest-dev:master.

@RonnyPfannschmidt
Copy link
Member

@nicoddemus good work, can you please add a paragraph on subtests as well

@nicoddemus
Copy link
Member Author

can you please add a paragraph on subtests as well

Definitely, thanks!

@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.807% when pulling 15cdf13 on nicoddemus:unittest-features into 8969bd4 on pytest-dev:master.

Copy link
Member

@hackebrot hackebrot left a comment

Choose a reason for hiding this comment

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

Few comments on wording and overall structure, but apart from that great work @nicoddemus! 📝 👏

to overwrite ``debug`` in the same way (this is also true for standard
unittest).
``pytest`` supports running Python `unittest.py style`_ tests out of the box.
It's meant for leveraging existing ``unittest``-style test suites
Copy link
Member

Choose a reason for hiding this comment

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

I think, it would be better to stick to one name:

`unittest.py style`_

vs.

``unittest``-style

``pytest`` supports running Python `unittest.py style`_ tests out of the box.
It's meant for leveraging existing ``unittest``-style test suites
to use pytest as a test runner and also allow to incrementally adapt
the test suite to take full advantage of pytest features.
Copy link
Member

Choose a reason for hiding this comment

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

pytest's features

to use pytest as a test runner and also allow to incrementally adapt
the test suite to take full advantage of pytest features.

To run an existing ``unittest``-style test suite using ``pytest``, simply type::
Copy link
Member

Choose a reason for hiding this comment

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

Remove simply. It's redundant 😄

Benefits
--------

You can make use of several pytest features, most without changing any existing code:
Copy link
Member

Choose a reason for hiding this comment

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

You can make use of several pytest features, in most cases without having to modify existing code:

.. _`setUpModule/tearDownModule`: https://docs.python.org/3/library/unittest.html#setupmodule-and-teardownmodule
.. _`subtests`: https://docs.python.org/3/library/unittest.html#distinguishing-test-iterations-using-subtests

Pytest currently does not support the following ``unittest`` features:
Copy link
Member

Choose a reason for hiding this comment

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

Up to this point pytest does not have support for the following unittest features:

Mixing pytest fixtures into unittest.TestCase style tests
-----------------------------------------------------------

pytest features in ``unittest.TestCase`` subclasses
Copy link
Member

Choose a reason for hiding this comment

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

Hmm I wonder if we can improve the structure of this document:

  • unittest.TestCase Support
    • Benefits
    • Limitations
    • pytest features in unittest.TestCase subclasses
    • Mixing pytest fixtures into unittest.TestCase subclasses using marks
    • Using autouse fixtures and accessing other fixtures
    • ...

I might be better to have an introduction at the top level and mention some of the limitations and link to the according section and then list some of the most important unittest features that pytest supports?! 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I agree the structure is not very appealing.

We might not use RST sessions, just make the title bold instead and list benefits/limitations etc in the introduction text.

Btw you're welcome to push to my branch if you want to take a stab at this yourself. 😉

Copy link
Member

Choose a reason for hiding this comment

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

I know, my friend, I know 😢

Don't have much time for FOSS at the moment. Otherwise I'd happily work on this with you.

Copy link
Member Author

Choose a reason for hiding this comment

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

No worries! I will take a stab at this again later then. 👍

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.007%) to 91.8% when pulling 37353a8 on nicoddemus:unittest-features into 8969bd4 on pytest-dev:master.

@nicoddemus
Copy link
Member Author

@hackebrot pushed requested changes.

@hackebrot
Copy link
Member

Great work @nicoddemus! 👍

@RonnyPfannschmidt RonnyPfannschmidt merged commit d5f4496 into pytest-dev:master Aug 5, 2017
@RonnyPfannschmidt
Copy link
Member

great collaboration, thanks

@nicoddemus nicoddemus deleted the unittest-features branch August 7, 2017 23:56
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

4 participants