Ejemplo n.º 1
0
def test_nothing():
    """ Verify that TypeError gets raised if function called with no arguments """
    with pytest.raises(TypeError) as excinfo:
        ans = tax_table()
Ejemplo n.º 2
0
def test_negative():
    """ Make sure negative input values are dealt with appropriately """
    ans = tax_table(-1e6)
    numpy.testing.assert_allclose(ans, 0)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
def test_str():
    """ Ensure TypeError gets raised if someone passes a string in """
    with pytest.raises(TypeError) as excinfo:
        ans = tax_table('nonsense')
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
def test_notax_edge():
    """ Check edge case on low tax, from below """
    ans = tax_table(18200)
    numpy.testing.assert_allclose(ans, 0)
Ejemplo n.º 7
0
def test_negative():
    ans = tax_table(-1e6)
    numpy.testing.assert_allclose(ans, 0)
Ejemplo n.º 8
0
def test_notax():
    ans = tax_table(500)
    numpy.testing.assert_allclose(ans, 0)
Ejemplo n.º 9
0
def test_str():
    with pytest.raises(TypeError) as excinfo:
        ans = tax_table('nonsense')
Ejemplo n.º 10
0
def test_nothing():
    with pytest.raises(TypeError) as excinfo:
        ans = tax_table()
Ejemplo n.º 11
0
def test_notax_over_edge():
    ans = tax_table(18201)
    numpy.testing.assert_allclose(ans, 0.19)
Ejemplo n.º 12
0
def test_notax_edge():
    ans = tax_table(18200)
    numpy.testing.assert_allclose(ans, 0)
Ejemplo n.º 13
0
def tot():
    total_tax = 0
    for income in taxable_incomes:
        total_tax += taxcode.tax_table(income)
    return total_tax
Ejemplo n.º 14
0
# 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))
Ejemplo n.º 15
0
def tot():
    """ Compute the total tax """
    total_tax = 0
    for income in taxable_incomes:
        total_tax += taxcode.tax_table(income)
    return total_tax