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鈥檒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
Merged

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

merged 8 commits into from Jul 6, 2017

Conversation

jamescooke
Copy link
Owner

@jamescooke jamescooke commented Jul 5, 2017

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

All suggestions welcome 馃槃

@jamescooke
Copy link
Owner Author

jamescooke commented Jul 5, 2017

TODO:

  • Set as published.
  • Add subscription info.

@@ -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
Copy link
Contributor

@adamchainz adamchainz Jul 6, 2017

Choose a reason for hiding this comment

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

oxford comma? 馃槈

Copy link
Owner Author

@jamescooke jamescooke Jul 6, 2017

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>`_.
Copy link
Contributor

@adamchainz adamchainz Jul 6, 2017

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 馃槈?

Copy link
Owner Author

@jamescooke jamescooke Jul 6, 2017

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.
Copy link
Contributor

@adamchainz adamchainz Jul 6, 2017

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.
Copy link
Contributor

@adamchainz adamchainz Jul 6, 2017

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
Copy link
Contributor

@adamchainz adamchainz Jul 6, 2017

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.
Copy link
Contributor

@adamchainz adamchainz Jul 6, 2017

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 馃槈

Copy link
Owner Author

@jamescooke jamescooke Jul 6, 2017

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.
Copy link
Contributor

@adamchainz adamchainz Jul 6, 2017

Choose a reason for hiding this comment

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

Looking forward! 馃憖

Copy link
Owner Author

@jamescooke jamescooke Jul 6, 2017

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! 馃槄

@jamescooke
Copy link
Owner Author

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
Copy link

@k0nG k0nG Jul 10, 2017

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.

Copy link
Owner Author

@jamescooke jamescooke Jul 10, 2017

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.

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

3 participants