Implement checks for raising messages with exceptions (#1113)

* Implement checks for messages being raised with exceptions
(Fixes #1080)

* Add self.assertRaisesWithMessage method to relevant exercise tests
    - Uses self.assertRaisesRegex
    - Checks only for the presence of a message, not content
* Add meaningful messages to failing examples
* octal: Switch to using a context manager for exception tests

* Add note regarding error messages to the insert

* simple-linked-list: Move hints.md to correct location

* simple-cipher: Remove extra whitespace from lines

* collatz-conjecture: Update hints.md

* Regenerate README to include exceptions section
This commit is contained in:
Nathan Parsons
2017-12-12 18:11:43 +00:00
committed by Corey McCandless
parent 2f93a626f1
commit f53e2ef08b
152 changed files with 2252 additions and 230 deletions

View File

@@ -25,7 +25,7 @@ class CircularBuffer(object):
def write(self, data):
if all(self.buffer):
raise BufferFullException
raise BufferFullException("Circular buffer is full")
self._update_buffer(data)
self.write_point = (self.write_point + 1) % len(self.buffer)
@@ -37,7 +37,7 @@ class CircularBuffer(object):
def read(self):
if not any(self.buffer):
raise BufferEmptyException
raise BufferEmptyException("Circular buffer is empty")
data = chr(self.buffer[self.read_point])
self.buffer[self.read_point] = 0
self.read_point = (self.read_point + 1) % len(self.buffer)