|
2 | 2 | import measure |
3 | 3 |
|
4 | 4 | class MeasureTest(unittest.TestCase): |
| 5 | + """ |
| 6 | + MeasureTest has PyUnit tests for measure.py |
| 7 | + """ |
5 | 8 |
|
6 | 9 | def setUp(self): |
7 | | - self.measure = measure.Measure("grpc_client_sent_messages_per_rpc", "Number of messages sent in the RPC", "1") |
| 10 | + """ |
| 11 | + setup performed before each test |
| 12 | + """ |
| 13 | + self.measure = measure.Measure("grpc_client_sent_messages_per_rpc", |
| 14 | + "Number of messages sent in the RPC", |
| 15 | + "1") |
8 | 16 |
|
9 | 17 | def test_measure_name(self): |
10 | | - self.assertEqual(self.measure.get_name(), "grpc_client_sent_messages_per_rpc", "get_name() method not working") |
| 18 | + """ |
| 19 | + tests measure module's get_name() method |
| 20 | + """ |
| 21 | + self.assertEqual(self.measure.get_name(), |
| 22 | + "grpc_client_sent_messages_per_rpc", |
| 23 | + "get_name() method not working") |
11 | 24 |
|
12 | 25 | def test_measure_description(self): |
13 | | - self.assertEqual(self.measure.get_description(), "Number of messages sent in the RPC", "get_description() method not working") |
| 26 | + """ |
| 27 | + tests measure module's get_description() method |
| 28 | + """ |
| 29 | + self.assertEqual(self.measure.get_description(), |
| 30 | + "Number of messages sent in the RPC", |
| 31 | + "get_description() method not working") |
14 | 32 |
|
15 | 33 | def test_measure_unit(self): |
16 | | - self.assertEqual(self.measure.get_unit(), "1", "get_unit() not working correctly") |
| 34 | + """ |
| 35 | + tests measure module's get_unit() method |
| 36 | + """ |
| 37 | + self.assertEqual(self.measure.get_unit(), |
| 38 | + "1", |
| 39 | + "get_unit() not working correctly") |
17 | 40 |
|
18 | 41 | def test_long_name_init(self): |
| 42 | + """ |
| 43 | + tests measure module's __init__() if the name str exceeds max length |
| 44 | + and assert that it raises ValueError as expected |
| 45 | + """ |
19 | 46 | with self.assertRaises(ValueError): |
20 | 47 | self.measure_exceeds_max_length = measure.Measure("a"*256, "some description", "1") |
21 | 48 |
|
22 | 49 | def test_unprintable_name_init(self): |
| 50 | + """ |
| 51 | + tests measure module's __init__() if the name str contains a non-printable ascii character |
| 52 | + and assert that it raises ValueError as expected |
| 53 | + """ |
23 | 54 | with self.assertRaises(ValueError): |
24 | 55 | chr_list = ['0x41', '0x1B', '0x42'] |
25 | 56 | non_printable_str = "".join([chr(int(x, 16)) for x in chr_list]) # 'AB\x1b' |
|
0 commit comments