Exemplo n.º 1
0
def test_term_creation():
    """Test the Term constructor.

    """
    v = Variable('foo')
    t = Term(v)
    assert t.variable() is v
    assert t.coefficient() == 1

    t = Term(v, 100)
    assert t.variable() is v
    assert t.coefficient() == 100

    assert str(t) == '100 * foo'
Exemplo n.º 2
0
def test_term_creation():
    """Test the Term constructor.

    """
    v = Variable('foo')
    t = Term(v)
    assert t.variable() is v
    assert t.coefficient() == 1

    t = Term(v, 100)
    assert t.variable() is v
    assert t.coefficient() == 100

    assert str(t) == '100 * foo'
Exemplo n.º 3
0
def test_term_creation():
    """Test the Term constructor.

    """
    v = Variable('foo')
    t = Term(v)
    assert t.variable() is v
    assert t.coefficient() == 1

    t = Term(v, 100)
    assert t.variable() is v
    assert t.coefficient() == 100

    assert str(t) == '100 * foo'

    with pytest.raises(TypeError) as excinfo:
        Term('')
    assert 'Variable' in excinfo.exconly()

    # ensure we test garbage collection
    del t
    gc.collect()
Exemplo n.º 4
0
def test_term_creation():
    """Test the Term constructor.

    """
    v = Variable('foo')
    t = Term(v)
    assert t.variable() is v
    assert t.coefficient() == 1

    t = Term(v, 100)
    assert t.variable() is v
    assert t.coefficient() == 100

    assert str(t) == '100 * foo'

    with pytest.raises(TypeError) as excinfo:
        Term('')
    assert 'Variable' in excinfo.exconly()

    # ensure we test garbage collection
    del t
    gc.collect()