| 29 | |
| 30 | |
| 31 | class IrisTest(unittest.TestCase): |
| 32 | |
| 33 | def setUp(self): |
| 34 | self._tmp_dir = tempfile.mkdtemp() |
| 35 | super(IrisTest, self).setUp() |
| 36 | |
| 37 | def tearDown(self): |
| 38 | if os.path.isdir(self._tmp_dir): |
| 39 | shutil.rmtree(self._tmp_dir) |
| 40 | super(IrisTest, self).tearDown() |
| 41 | |
| 42 | def testTrainAndSaveNonSequential(self): |
| 43 | final_train_accuracy = iris.train(100, self._tmp_dir) |
| 44 | self.assertGreater(final_train_accuracy, 0.9) |
| 45 | |
| 46 | # Check that the model json file is created. |
| 47 | json.load(open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) |
| 48 | |
| 49 | def testTrainAndSaveSequential(self): |
| 50 | final_train_accuracy = iris.train(100, self._tmp_dir, sequential=True) |
| 51 | self.assertGreater(final_train_accuracy, 0.9) |
| 52 | |
| 53 | # Check that the model json file is created. |
| 54 | json.load(open(os.path.join(self._tmp_dir, 'model.json'), 'rt')) |
| 55 | |
| 56 | |
| 57 | if __name__ == '__main__': |
nothing calls this directly
no outgoing calls
no test coverage detected