Skip to content

Commit

Permalink
Allow for unsolvable cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mramshaw committed Nov 30, 2018
1 parent 2ca73b0 commit 8da5442
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ Code coverage is __88%__ which seems acceptable.
[Opinions differ on what is an acceptable level of code coverage.
As 100% code coverage is not always reasonable (for instance in this
case), my opinion is that 70% is a minimum acceptable value. But a
higher level of code coverage is of course very desirable. Adding
a new test for the first uncaught exception (__ExceptionWithDuplicateMember__)
raises the code coverage to __89%__ - which is an improvement.]
higher level of code coverage is of course very desirable.]

Of course, we can drill down into the code with an HTML report as well:

Expand Down Expand Up @@ -148,14 +146,18 @@ Coverage HTML written to dir htmlcov
$
```

Looking at `htmlcov/index.html` and driling down into `secret_santa.py` we can see that
Looking at `htmlcov/index.html` and drilling down into `secret_santa.py` we can see that
we do not have any coverage in our `main` routine (this is expected) but there are also
two exceptions that do not get tested. The second is a catch-all, so cannot be fixed.

However, the first exception not being tested is an oversight. This means another test
should be written to check for this exception. And so code coverage has highlighted a
soft area in our testing. This is unlikely to be critical, but better safe than sorry.

[Adding a test for the first uncaught exception raises the code coverage to __89%__.
But then the addition of more code to the `main` routine dropped this number back
down to __88%__.]

## Run

Run the application as follows:
Expand Down Expand Up @@ -213,7 +215,6 @@ Family member (or CR to stop):
All family members entered, working out exchanges
Not enough unpartnered members for a solution!
$
```
Expand Down
2 changes: 1 addition & 1 deletion secret_santa.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def match_members(self, items):
print "Okay, stopping now"
sys.exit(1)
except gift_exchange.NoSolutionPossibleException as nspe:
print nspe.args[0], "\n"
print nspe.args[0]
sys.exit(1)

print "\nI hope your gathering is successful!"

0 comments on commit 8da5442

Please sign in to comment.