-
Notifications
You must be signed in to change notification settings - Fork 3
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
June's blog post: Arrange Act Assert guide #10
Conversation
TODO:
|
content/1609-aaa-pyconuk.rst
Outdated
@@ -13,7 +13,7 @@ At `PyConUK 2016 | |||
<http://2016.pyconuk.org/talks/cleaner-unit-testing-with-the-arrange-act-assert-pattern/>`_ | |||
I spoke about the Arrange Act Assert pattern and how it can help clean up unit | |||
tests. I plan to write a short guide to AAA for Python developers and will | |||
link to that from here when done - meanwhile, below are my slides and links | |||
link to that from here when done - meanwhile, below is the video of the talk, my slides and links |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oxford comma? 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bad phrase will be removed when I link to the guide now.
@@ -74,5 +81,4 @@ Finally | |||
------- | |||
|
|||
Thanks again to `Carles <https://github.com/txels>`_ for introducing me to the | |||
AAA pattern. Check out his `data driven tests library | |||
<https://github.com/txels/ddt>`_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOI, why remove the ref to ddt? Found other solutions like pytest.mark.parametrize
😉?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes exactly that 😊
:status: draft | ||
|
||
This is the first post in a series exploring the Arrange Act Assert pattern and | ||
how to apply it to Python unit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe scrap the word 'unit'? It can be applied to functional tests too, etc.
|
||
I'll now go into detail on each of these parts using Pytest and a simple toy | ||
test example. We'll write a simple happy-path test for Python's builtin | ||
``list.reverse`` function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're mixing "I'll" / "We'll" in this paragraph, which sounds a bit confused
* We all love `PEP008 <https://www.python.org/dev/peps/pep-0008/>`_, so we want | ||
tests to pass ``flake8`` linting. | ||
|
||
* `PEP020 <https://www.python.org/dev/peps/pep-0020/>`_ is also something we |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this as the 'zen of python' instead of PEP 20, I had to click the link to remind myself that's what it is - maybe mention it as:
PEP020, The Zen of Python, is also something...
Docstring | ||
--------- | ||
|
||
A short single line statement about the behaviour under test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I feel good test method names can make docstrings redundant in simple tests, and developers also find writing english harder than code 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a helpful point. I've realised while considering this that the docstring is not really part of the pattern - it's my own addition. I'll rephrase to indicate that.
will explore strategies for extracting common assertion code and testing it | ||
in its own right. | ||
|
||
Links will appear above when I complete these follow up posts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking forward! 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me too! I hope that I can keep up with the one post per month schedule! 😅
Thanks for the revew @adamchainz ... merging and publishing now. |
Background | ||
---------- | ||
|
||
I'll now go into detail on each of these parts using Pytest and a toy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean toy here or tox? Just checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely mean "toy". This is just a toy example where I write a test for something in stdlib.
Late, but 90% of the way there. Needs proof reading.
All suggestions welcome 😄