--------
Installing chromedriver | 1. Download binary from https://sites.google.com/a/chromium.org/chromedriver/downloads 2. Copy binary to /usr/local/bin (or on any of your $PATH) |
Quality Control
---------------
`doctest` | Performs tests on examples in docstings. This makes sure that the examples are align with the def average(values): """Computes the arithmetic mean of a list of numbers.
>>> print(average([20, 30, 70])) 40.0 """ return sum(values) / len(values)
import doctest doctest.testmod() # automatically validate the embedded test |
`unittest` | Allows tests to be maintained on a separate file. import unittest
class TestStatisticalFunctions(unittest.TestCase):
def test_average(self): self.assertEqual(average([20, 30, 70]), 40.0) self.assertEqual(round(average([1, 5, 7]), 1), 4.3) with self.assertRaises(ZeroDivisionError): average([]) with self.assertRaises(TypeError): average(20, 30, 70)
unittest.main() # Calling from the command line invokes all tests |
No comments:
Post a Comment