Пример #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'
Пример #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'
Пример #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()
Пример #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()