def test_nothing(): """ Verify that TypeError gets raised if function called with no arguments """ with pytest.raises(TypeError) as excinfo: ans = tax_table()
def test_negative(): """ Make sure negative input values are dealt with appropriately """ ans = tax_table(-1e6) numpy.testing.assert_allclose(ans, 0)
def test_notax_over_edge(): """ Check edge case on low tax, from above """ ans = tax_table(18201) numpy.testing.assert_allclose(ans, 0.19)
def test_str(): """ Ensure TypeError gets raised if someone passes a string in """ with pytest.raises(TypeError) as excinfo: ans = tax_table('nonsense')
def test_notax(): """ Test when a low income is provided - calculated tax should be zero """ ans = tax_table(500) # Check that the tax is very close to zero to deal with floating-point precision issues numpy.testing.assert_allclose(ans, 0)
def test_notax_edge(): """ Check edge case on low tax, from below """ ans = tax_table(18200) numpy.testing.assert_allclose(ans, 0)
def test_negative(): ans = tax_table(-1e6) numpy.testing.assert_allclose(ans, 0)
def test_notax(): ans = tax_table(500) numpy.testing.assert_allclose(ans, 0)
def test_str(): with pytest.raises(TypeError) as excinfo: ans = tax_table('nonsense')
def test_nothing(): with pytest.raises(TypeError) as excinfo: ans = tax_table()
def test_notax_over_edge(): ans = tax_table(18201) numpy.testing.assert_allclose(ans, 0.19)
def test_notax_edge(): ans = tax_table(18200) numpy.testing.assert_allclose(ans, 0)
def tot(): total_tax = 0 for income in taxable_incomes: total_tax += taxcode.tax_table(income) return total_tax
# Taxable income of 11 million people import numpy taxable_incomes = numpy.random.uniform(5e3, 3e5, int(11e6)) # Calculate the tax table. import taxcode total_tax = 0 for income in taxable_incomes: total_tax += taxcode.tax_table(income) print(""" Australian Tax due for 2015/2016 ================================ AUD {:.2f} BN """.format(total_tax / 1e9))
def tot(): """ Compute the total tax """ total_tax = 0 for income in taxable_incomes: total_tax += taxcode.tax_table(income) return total_tax