|
1 | 1 | from datetime import date, timedelta |
| 2 | +from functools import partial |
| 3 | +from types import InstanceType, MethodType |
2 | 4 | import json |
3 | 5 | import unittest |
4 | 6 |
|
@@ -113,11 +115,17 @@ def test_add_time_series(self): |
113 | 115 | self.assertEqual(self.flot._options['xaxis'], |
114 | 116 | {'mode': 'time'}) |
115 | 117 |
|
116 | | - |
117 | 118 | def test_bogus_call(self): |
118 | | - "test a bogus method on __getattr__" |
119 | | - self.assertRaises(AttributeError, lambda: self.add_shrimp) |
120 | | - |
| 119 | + """make sure explicit and dynamic instance methods work, and that |
| 120 | + bogus attribute access fails as expected""" |
| 121 | + self.assertRaises(AttributeError, lambda: self.flot.add_shrimp) |
| 122 | + self.assertRaises(AttributeError, lambda: self.flot.minus_bars) |
| 123 | + self.assertRaises(AttributeError, lambda: self.flot.asdf) |
| 124 | + self.assertTrue(isinstance(self.flot.add_bars, partial)) |
| 125 | + self.assertTrue(isinstance(self.flot.add_line, partial)) |
| 126 | + self.assertTrue(isinstance(self.flot.add_points, partial)) |
| 127 | + self.assertTrue(isinstance(self.flot.add_series, MethodType)) |
| 128 | + |
121 | 129 | def test_empty_options_json(self): |
122 | 130 | "make sure conversion to JSON works for default options" |
123 | 131 | self.assertEqual("{}", self.flot.options_json) |
|
0 commit comments