Skip to content

Commit 8da5442

Browse files
committed
Allow for unsolvable cases
1 parent 2ca73b0 commit 8da5442

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ Code coverage is __88%__ which seems acceptable.
113113
[Opinions differ on what is an acceptable level of code coverage.
114114
As 100% code coverage is not always reasonable (for instance in this
115115
case), my opinion is that 70% is a minimum acceptable value. But a
116-
higher level of code coverage is of course very desirable. Adding
117-
a new test for the first uncaught exception (__ExceptionWithDuplicateMember__)
118-
raises the code coverage to __89%__ - which is an improvement.]
116+
higher level of code coverage is of course very desirable.]
119117

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

@@ -148,14 +146,18 @@ Coverage HTML written to dir htmlcov
148146
$
149147
```
150148

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

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

157+
[Adding a test for the first uncaught exception raises the code coverage to __89%__.
158+
But then the addition of more code to the `main` routine dropped this number back
159+
down to __88%__.]
160+
159161
## Run
160162

161163
Run the application as follows:
@@ -213,7 +215,6 @@ Family member (or CR to stop):
213215
All family members entered, working out exchanges
214216
215217
Not enough unpartnered members for a solution!
216-
217218
$
218219
```
219220

secret_santa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def match_members(self, items):
161161
print "Okay, stopping now"
162162
sys.exit(1)
163163
except gift_exchange.NoSolutionPossibleException as nspe:
164-
print nspe.args[0], "\n"
164+
print nspe.args[0]
165165
sys.exit(1)
166166

167167
print "\nI hope your gathering is successful!"

0 commit comments

Comments
 (0)