コード例 #1
0
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.

"""Tests for checkers.parameterization."""

import checkers
from checkers import asserts
from checkers import parameterization
from checkers.runners import pyunit


@checkers.test
def test_parameterization_init():
  param = parameterization.Parameterization('name')
  asserts.are_equal(param.name, 'name')
  asserts.is_empty(param.variables)


@checkers.test
def test_parameterization_with_variables():
  variables = {'foo': 0, 'bar': 2, 'baz': 4, 'quux': 8}
  param = parameterization.Parameterization('name', variables)
  asserts.are_equal(param.name, 'name')
  asserts.has_length(param.variables, 4)


if __name__ == '__main__':
  pyunit.main()
コード例 #2
0
        'y': 1,
        'expected': 1,
        'test_suites': ['identity']
    },
    '1_2_3': {
        'x': 1,
        'y': 2,
        'expected': 3
    },
    '4_8_12': {
        'x': 4,
        'y': 8,
        'expected': 12
    },
})
@checkers.test
def test_add(x, y, expected):
    asserts.are_equal(x + y, expected)


def create_test_run():
    test_run = checkers.TestRun.from_module()
    test_run.test_suites['addition'].register(test_add)
    subtraction_suite = checkers.TestSuite.from_module(subtraction_tests)
    test_run.test_suites.register(subtraction_suite)
    return test_run


if __name__ == '__main__':
    pyunit.main(test_run=create_test_run())
コード例 #3
0
# Copyright 2015 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing, software
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.
"""Example of a very simple test of the 'hello world' variety."""

import checkers
from checkers import asserts
from checkers.runners import pyunit


@checkers.test
def test_hello_world():
    """Simple test that asserts that the hello string is not empty."""
    hello = 'hello, world'
    asserts.is_not_empty(hello)


if __name__ == '__main__':
    pyunit.main()
コード例 #4
0
ファイル: fixtures_test.py プロジェクト: pombredanne/checkers
    asserts.are_equal(calculator.add(2, 2), 4)
    print "1 + 1 = 2"


@checkers.setup(celebrate_evenness)
@checkers.test
def test_add_2_2_4(calculator):
    asserts.are_equal(calculator.add(2, 2), 4)
    print "2 + 2 = 4"


@checkers.setup(celebrate_evenness)
@checkers.test
def test_add_4_8_12(calculator):
    asserts.are_equal(calculator.add(4, 8), 12)
    print "4 + 8 = 12"


def create_test_run():
    test_run = checkers.TestRun.from_module()
    test_run.setup.register(logging_test_run_setup)
    test_run.teardown.register(logging_test_run_teardown)
    test_run.test_case_setup.register(logging_test_case_setup)
    test_run.test_case_setup.register(register_calculator)
    test_run.test_case_teardown.register(logging_test_case_teardown)
    return test_run


if __name__ == "__main__":
    pyunit.main(test_run=create_test_run())