Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_printtable(self):
testtable = censusdata.censustable('acs5', 2015, 'B19013')
printedtable = io.StringIO()
sys.stdout = printedtable
censusdata.printtable(testtable)
sys.stdout = sys.__stdout__
self.assertEqual(printedtable.getvalue(), textwrap.dedent(
'''\
Variable | Table | Label | Type
-------------------------------------------------------------------------------------------------------------------
B19013_001E | B19013. Median Household Incom | Median household income in the past 12 months (in 2015 I | int
-------------------------------------------------------------------------------------------------------------------
'''))
printedtable.close()
printedtable = io.StringIO()
sys.stdout = printedtable
censusdata.printtable(testtable, moe=True)
sys.stdout = sys.__stdout__
self.assertEqual(printedtable.getvalue(), textwrap.dedent(
'''\
Variable | Table | Label | Type
testtable = censusdata.censustable('acs5', 2015, 'B19013')
printedtable = io.StringIO()
sys.stdout = printedtable
censusdata.printtable(testtable)
sys.stdout = sys.__stdout__
self.assertEqual(printedtable.getvalue(), textwrap.dedent(
'''\
Variable | Table | Label | Type
-------------------------------------------------------------------------------------------------------------------
B19013_001E | B19013. Median Household Incom | Median household income in the past 12 months (in 2015 I | int
-------------------------------------------------------------------------------------------------------------------
'''))
printedtable.close()
printedtable = io.StringIO()
sys.stdout = printedtable
censusdata.printtable(testtable, moe=True)
sys.stdout = sys.__stdout__
self.assertEqual(printedtable.getvalue(), textwrap.dedent(
'''\
Variable | Table | Label | Type
-------------------------------------------------------------------------------------------------------------------
B19013_001E | B19013. Median Household Incom | Median household income in the past 12 months (in 2015 I | int
B19013_001M | B19013. Median Household Incom | !! Margin of Error for Median household income in the pa | int
-------------------------------------------------------------------------------------------------------------------
'''))
printedtable.close()