Conversation
|
Thanks @marqh ! I'll have time to look this over on friday. Talk to you then. |
|
Sorry, @marqh . This fell off of my radar. I will look this weekend at this. For real this time. |
katyhuff
left a comment
There was a problem hiding this comment.
I'm really sorry @marqh that this took a long time. Generally, I just think an explanation at the beginning to explain why and when someone might want to know unittest in addition to pytest, would be appropriate. Also, a couple of line length and brit->american spelling suggestions follow. Thanks for the contribution!
| @@ -1,159 +0,0 @@ | |||
| <!DOCTYPE html> | |||
There was a problem hiding this comment.
Why was this file deleted?
| @@ -1,114 +0,0 @@ | |||
| <!DOCTYPE html> | |||
| > - | ||
| > - | ||
|
|
||
| The Python standard library provides a module for writing and running tests, called `unittest`, which is documented for [Python3.6](https://docs.python.org/3.6/library/unittest.html?highlight=unittest#module-unittest) and [Python2.7](https://docs.python.org/2/library/unittest.html?highlight=unittest#module-unittest). |
There was a problem hiding this comment.
line too long. Please keep lines, even text, under 80 chars.
|
|
||
| The Python standard library provides a module for writing and running tests, called `unittest`, which is documented for [Python3.6](https://docs.python.org/3.6/library/unittest.html?highlight=unittest#module-unittest) and [Python2.7](https://docs.python.org/2/library/unittest.html?highlight=unittest#module-unittest). | ||
|
|
||
| This module is useful for writing all styles of test, including unit tests and functional tests. |
There was a problem hiding this comment.
Since we already cover pytest, perhaps this would be a good place to justify the need to learn both (or when it is or is not necessary to learn both). My general feeling is that pytest is much more friendly to beginners.
|
|
||
| ## Functional Tests | ||
|
|
||
| Functional testing is a way of checking software to ensure that it has all the required functionality that's specified within its functional requirements. This will test many methods and may interact with dependencies like file access. |
|
|
||
| ## Unittest TestCases | ||
|
|
||
| unittest is part of the Python core library; it defines a class, unittest.TestCase which provides lots of useful machinery for writing tests. We define classes which inherit from unittest.TestCase, bringing in their useful behaviour for us to apply to our tests. |
|
|
||
| unittest is part of the Python core library; it defines a class, unittest.TestCase which provides lots of useful machinery for writing tests. We define classes which inherit from unittest.TestCase, bringing in their useful behaviour for us to apply to our tests. | ||
|
|
||
| The reuse of objects in this way is a really useful programming approach. Don't worry if it is new to you. For testing with unittest, you can just think of it as a framework to fit your test cases into. |
|
|
||
| The reuse of objects in this way is a really useful programming approach. Don't worry if it is new to you. For testing with unittest, you can just think of it as a framework to fit your test cases into. | ||
|
|
||
| We can rewrite the tests from the previous page, using the Unittest approach. |
There was a problem hiding this comment.
line length. Otherwise, great transition.
|
|
||
| ~~~ | ||
|
|
||
| Unittest reports failures and errors on test cases, which we can see if we run Python2, as one of our tests only passes in Python3: |
|
|
||
| ## Unittest | ||
|
|
||
| The `unittest` module also provides this functionality for us with the `setUp` and `tearDown` methods that allow you to define instructions that will be executed before and after each test method (note the capitalisation of these names, which is important). |
There was a problem hiding this comment.
perhaps you can use the notion of "fixtures" here, so that the student recognize the vocabulary that they just learned in the previous lesson?
|
Hi @marqh , have you been able to look at these change requests? |
Hi @katyhuff @gvwilson
this is a replacement for
swcarpentry#2
targeting this repository; as requested