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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

June's blog post: Arrange Act Assert guide #10

Merged
merged 8 commits into from Jul 6, 2017

Conversation

3 participants
@jamescooke
Owner

jamescooke commented Jul 5, 2017

Late, but 90% of the way there. Needs proof reading.

All suggestions welcome 馃槃

@jamescooke

This comment has been minimized.

Show comment
Hide comment
@jamescooke

jamescooke Jul 5, 2017

Owner

TODO:

  • Set as published.
  • Add subscription info.
Owner

jamescooke commented Jul 5, 2017

TODO:

  • Set as published.
  • Add subscription info.
Show outdated Hide outdated content/1609-aaa-pyconuk.rst
@@ -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

This comment has been minimized.

@adamchainz

adamchainz Jul 6, 2017

oxford comma? 馃槈

@adamchainz

adamchainz Jul 6, 2017

oxford comma? 馃槈

This comment has been minimized.

@jamescooke

jamescooke Jul 6, 2017

Owner

This bad phrase will be removed when I link to the guide now.

@jamescooke

jamescooke Jul 6, 2017

Owner

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>`_.

This comment has been minimized.

@adamchainz

adamchainz Jul 6, 2017

OOI, why remove the ref to ddt? Found other solutions like pytest.mark.parametrize 馃槈?

@adamchainz

adamchainz Jul 6, 2017

OOI, why remove the ref to ddt? Found other solutions like pytest.mark.parametrize 馃槈?

This comment has been minimized.

@jamescooke

jamescooke Jul 6, 2017

Owner

Yes exactly that 馃槉

@jamescooke

jamescooke Jul 6, 2017

Owner

Yes exactly that 馃槉

Show outdated Hide outdated content/1706-arrange-act-assert-for-python.rst
: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.

This comment has been minimized.

@adamchainz

adamchainz Jul 6, 2017

maybe scrap the word 'unit'? It can be applied to functional tests too, etc.

@adamchainz

adamchainz Jul 6, 2017

maybe scrap the word 'unit'? It can be applied to functional tests too, etc.

Show outdated Hide outdated content/1706-arrange-act-assert-for-python.rst
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.

This comment has been minimized.

@adamchainz

adamchainz Jul 6, 2017

You're mixing "I'll" / "We'll" in this paragraph, which sounds a bit confused

@adamchainz

adamchainz Jul 6, 2017

You're mixing "I'll" / "We'll" in this paragraph, which sounds a bit confused

Show outdated Hide outdated content/1706-arrange-act-assert-for-python.rst
* 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

This comment has been minimized.

@adamchainz

adamchainz Jul 6, 2017

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...

@adamchainz

adamchainz Jul 6, 2017

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...

Show outdated Hide outdated content/1706-arrange-act-assert-for-python.rst
Docstring
---------
A short single line statement about the behaviour under test.

This comment has been minimized.

@adamchainz

adamchainz Jul 6, 2017

Personally I feel good test method names can make docstrings redundant in simple tests, and developers also find writing english harder than code 馃槈

@adamchainz

adamchainz Jul 6, 2017

Personally I feel good test method names can make docstrings redundant in simple tests, and developers also find writing english harder than code 馃槈

This comment has been minimized.

@jamescooke

jamescooke Jul 6, 2017

Owner

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.

@jamescooke

jamescooke Jul 6, 2017

Owner

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.

This comment has been minimized.

@adamchainz

adamchainz Jul 6, 2017

Looking forward! 馃憖

@adamchainz

adamchainz Jul 6, 2017

Looking forward! 馃憖

This comment has been minimized.

@jamescooke

jamescooke Jul 6, 2017

Owner

Me too! I hope that I can keep up with the one post per month schedule! 馃槄

@jamescooke

jamescooke Jul 6, 2017

Owner

Me too! I hope that I can keep up with the one post per month schedule! 馃槄

@jamescooke

This comment has been minimized.

Show comment
Hide comment
@jamescooke

jamescooke Jul 6, 2017

Owner

Thanks for the revew @adamchainz ... merging and publishing now.

Owner

jamescooke commented Jul 6, 2017

Thanks for the revew @adamchainz ... merging and publishing now.

@jamescooke jamescooke merged commit 6ecc217 into master Jul 6, 2017

@jamescooke jamescooke deleted the aaa-guide branch Jul 6, 2017

Background
----------
I'll now go into detail on each of these parts using Pytest and a toy

This comment has been minimized.

@k0nG

k0nG Jul 10, 2017

Do you mean toy here or tox? Just checking.

@k0nG

k0nG Jul 10, 2017

Do you mean toy here or tox? Just checking.

This comment has been minimized.

@jamescooke

jamescooke Jul 10, 2017

Owner

I definitely mean "toy". This is just a toy example where I write a test for something in stdlib.

@jamescooke

jamescooke Jul 10, 2017

Owner

I definitely mean "toy". This is just a toy example where I write a test for something in stdlib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment