Fix statement about running coverage

This commit is contained in:
Shauna 2014-11-25 12:57:02 -05:00
parent c7fb36898d
commit 988c93c9af
2 changed files with 15 additions and 15 deletions

View File

@ -1,12 +1,6 @@
## What is this?
oh-irc-bot (or "WelcomeBot", its IRC nick) is a bot for welcoming people into the #openhatch irc channel
when no one is paying attention. The goals are to:
1. alert community members when someone new enters the room and says hello (either by using their nick
in a response, or by sending a private message)
2. help a person to feel welcome even when there's no one around, and providing more information about
staying in touch
oh-irc-bot (or "WelcomeBot", its IRC nick) is a bot for welcoming people into the #openhatch irc channel when no one is paying attention. It has two main goals: first, to alert community members when someone new enters the room and says hello (either by using their nick in a response, or by sending a private message). Second, it helps the new person to feel welcome even when there's no one around, and provides more information to them about staying in touch.
## Basic Structure
@ -16,11 +10,12 @@ staying in touch
2. If someone says hello to the bot, the bot says hello back.
3. If someone asks the bot for information (via key phrases like "help", "faq", etc) the bot explains what it is and links to this repository.
The repository also contains <code>test_bot.py</code>, which is a set of automated tests for the bot. To learn more about these, see __Testing__ below. <code>test_nicks.csv</code>, which is the set of nicks used for the automated tests.
The repository contains <code>test_bot.py</code>, which is a set of automated tests for the bot. To learn more about these, see __Testing__ below or [the testing tutorial](https://github.com/shaunagm/WelcomeBot/blob/master/docs/testing.md). It also contains <code>test_nicks.csv</code>, the set of nicks used for the automated tests.
Finally, we have a docs folder which contains tutorial-style instructions for various concepts used by WelcomeBot. Currently there is one tutorial, for unit testing. [Check it out!](https://github.com/shaunagm/WelcomeBot/blob/master/docs/testing.md)
Finally, we have a docs folder which contains tutorial-style instructions for various concepts used by WelcomeBot. Currently there is one tutorial, for unit testing.
## Setting up
Currently, the bot is only compatible up to Python 2.7.
To run the bot:
@ -52,16 +47,19 @@ When creating tests, you can use the following series of commands to see whether
<code>
./bin/coverage run test_bot.py
./bin/coverage html
</code>
_Note_: You will likely need to install coverage. The above command assumes you have installed it to a virtual environment. If you haven't, the command to use is: <code>coverage run test_bot.py</code>
You can then see the results in `htmlcov/index.html`.
_Note_: You will likely need to install coverage. The above command assumes you have installed it to a virtual environment. If you haven't, use `coverage` instead of `bin/coverage`, for example: <code>coverage run test_bot.py</code>
## How to help
The [issue tracker](https://github.com/shaunagm/oh-irc-bot/issues?state=open) lists improvements we want to make. I strongly encourage you to contact me and say hello before you get started (I am shauna on the #openhatch IRC). Please feel free to submit pull requests to address these issues. If you're not familiar with how to do this using github, see [here](https://openhatch.org/wiki/Git_Basics). You can also always ask me for help or clarification.
The [issue tracker](https://github.com/shaunagm/oh-irc-bot/issues?state=open) lists improvements we want to make. Tasks that are better for newcomers are labelled [first task](https://github.com/shaunagm/WelcomeBot/labels/first%20task).
I strongly encourage you to contact me and say hello before you get started (I am shauna on the #openhatch IRC). Please feel free to submit pull requests to address these issues. If you're not familiar with how to do this using github, see [here](https://openhatch.org/wiki/Git_Basics). You can also always ask me for help or clarification.
## Credit
This bot was adapted from code found [here](http://wiki.shellium.org/w/Writing_an_IRC_bot_in_Python).
Also [this](http://docs.python.org/2/library/queue.html) has been very helpful.

View File

@ -121,7 +121,7 @@ Let's take a look at some output you might see. First, there is a series of dot
...........F.FF.....EE.......F
Each dot or letter refers to a specific test being run. An F means that the test failed. An E means that there was an error.
Each dot or letter refers to a specific test being run. An F means that the test failed. An E means that there was an error. A failed test is one in which the assert statement is incorrect, whereas a test that returns an error had some bug in the test that prevented it from reaching or finishing the assert statement.
Let's take a closer look at what a failed test looks like. I'm going to generate an error by altering `test_custom_wait_time()` to specify the wrong amount in `assertEqual()`. You can cause similar test failures by changing assertions in `test_bot.py`.
@ -148,10 +148,12 @@ Different types of failures will give different output of varying helpfulness.
If you want to expand the tests to cover a new piece of code -- either code you have written, or that someone else has - you might find [Coverage](http://nedbatchelder.com/code/coverage/) to be a useful tool. After installing coverage, you can run it, either in a virtual environment:
./bin/coverage run test_bot.py
./bin/coverage html
Or not in a virtual environment:
coverage run test_bot.py
coverage html
This will generate an html file which can be found by opening `htmlcov/index.html`. This file gives you a report on the percentage of code covered by tests. If you click the file being tested (not the test file, which should be covered 100%) you'll see a handy color-coded copy of the file indicated what is covered and what isn't. Each statement is either covered ("run"), not covered ("missing") or excluded. Excluded statements are excluded via the comment `pragma: no cover`, which we've used for WelcomeBot to ignore code interfacing with the socket library, as we're not sure how to test that yet.