|
2 | 2 |
|
3 | 3 | # standard library |
4 | 4 | import argparse |
| 5 | +import sys |
5 | 6 | import unittest |
6 | 7 | from unittest.mock import MagicMock |
| 8 | +from io import StringIO |
7 | 9 |
|
8 | 10 | # first party |
9 | 11 | from delphi.utils.geo.locations import Locations |
10 | 12 | from delphi.epidata.acquisition.fluview.impute_missing_values import ( |
11 | 13 | get_argument_parser, |
12 | 14 | get_lag_and_ili, |
13 | 15 | impute_missing_values, |
14 | | - StatespaceException, |
15 | 16 | ) |
16 | 17 |
|
17 | 18 | # py3tester coverage target |
@@ -87,8 +88,12 @@ def test_impute_missing_values_vipr(self): |
87 | 88 | db.get_known_values.return_value = known_data |
88 | 89 |
|
89 | 90 | db.find_missing_rows.return_value = [(201340, 201340)] |
90 | | - with self.assertRaises(Exception): |
91 | | - impute_missing_values(db, test_mode=True) |
| 91 | + |
| 92 | + capturedOutput = StringIO() |
| 93 | + sys.stdout = capturedOutput |
| 94 | + impute_missing_values(db, test_mode=True) |
| 95 | + sys.stdout = sys.__stdout__ |
| 96 | + self.assertTrue("system is underdetermined" in capturedOutput.getvalue().split("\n")) |
92 | 97 |
|
93 | 98 | db.find_missing_rows.return_value = [(201339, 201339)] |
94 | 99 | impute_missing_values(db, test_mode=True) |
@@ -131,5 +136,8 @@ def test_impute_missing_values_underdetermined(self): |
131 | 136 | db.find_missing_rows.return_value = [(201740, 201740)] |
132 | 137 | db.get_known_values.return_value = known_data |
133 | 138 |
|
134 | | - with self.assertRaises(StatespaceException): |
135 | | - impute_missing_values(db, test_mode=True) |
| 139 | + capturedOutput = StringIO() |
| 140 | + sys.stdout = capturedOutput |
| 141 | + impute_missing_values(db, test_mode=True) |
| 142 | + sys.stdout = sys.__stdout__ |
| 143 | + self.assertTrue("system is underdetermined" in capturedOutput.getvalue().split("\n")) |
0 commit comments