def test_to_usd():
    # function should add dollar sign and transform numeric object into string
    assert to_usd(4.50) == '$4.50'
    # function should round to two decimal places
    assert to_usd(4.5) == '$4.50'
    assert to_usd(4.5555) == '$4.56'
    # function should apply commas for numbers greater than 1,000
    assert to_usd(1234567890.5555) == '$1,234,567,890.56'
Example #2
0
def test_to_usd():
    result = to_usd(70.6)
    assert result == "$70.60"

    result = to_usd(70.389394)
    assert result == "$70.39"

    result = to_usd(70.8)
    assert result == "$70.80"
def test_to_usd():
    #Tests whether number is returned with $ sign and two decimal places
    assert to_usd(10) == "$10.00"

    #Tests whether number rounds decimal places
    assert to_usd(10.33333333333333) == "$10.33"

    #Tests whether there is a thousand seperator
    assert to_usd(10000) == "$10,000.00"
Example #4
0
def test_to_usd():
    result = to_usd(1500)
    assert result == "$1,500.00"

    result = to_usd(98.78384)
    assert result == "$98.78"

    result = to_usd(2.5)
    assert result == "$2.50"
def test_to_usd():

    assert to_usd(2.5) == "$2.50"

    assert to_usd(2.50) == "$2.50"

    assert to_usd(2.555556) == "$2.56"

    assert to_usd(1234567890.678) == "$1,234,567,890.68"

    assert to_usd(2.555556) == "$2.56"
def test_to_usd():
    # it should apply USD formatting
    assert to_usd(4.50) == "$4.50"

    # it should display two decimal places
    assert to_usd(4.5) == "$4.50"

    # it should round to two places
    assert to_usd(4.55555) == "$4.56"

    # it should display thousands separators
    assert to_usd(1234567890.5555555) == "$1,234,567,890.56"
Example #7
0
def test_to_usd():
    """
    Tests that the to_usd function correctly reformats price values in US dollars.
    """
    # it should apply USD formatting
    assert to_usd(4.50) == "$4.50"

    # it should display two decimal places
    assert to_usd(4.5) == "$4.50"

    # it should round to two places
    assert to_usd(4.55555) == "$4.56"

    # it should display thousands separators
    assert to_usd(1234567890.5555555) == "$1,234,567,890.56"
Example #8
0
def test_to_usd():
    """
     tests that to_usd() creates a string from a float that does the following:
              1) converts to two decimals
              2) includes commas for thousands place
              3) includes a dollar sign
     """
    price = 34903.727
    result = to_usd(price)
    assert result == "$34,903.73"
def test_to_usd():
    result = to_usd(3)
    assert result == "$3.00"
Example #10
0
def test_usd():
    result = to_usd(4)
    assert result == "$4.00"
Example #11
0
def test_to_usd():
    result = to_usd(3.4)
    assert result == "$3.40"
Example #12
0
def test_to_usd():
    result = to_usd(3.47)
    assert result == f"${3.47:,.2f}"
def test_to_usd():
	result = to_usd(5200.2)
	assert result == "$5200.20"