예제 #1
0
def test_context_init():
  tc = _DummyTestCase()
  tr = _DummyTestRun()
  ctx = context.Context(tc, tr)
  asserts.are_same(tc, ctx.test_case)
  asserts.are_same(tr, ctx.test_run)
  asserts.are_equal(len(ctx.variables), 1)
  asserts.is_in('context', ctx.variables)
예제 #2
0
def test_context_init_with_args():
  tc = _DummyTestCase()
  tr = _DummyTestRun()
  ctx = context.Context(tc, tr, foo='foo', bar=2)
  asserts.are_same(tc, ctx.test_case)
  asserts.are_same(tr, ctx.test_run)
  asserts.are_equal(len(ctx.variables), 3)
  asserts.are_equal(ctx.variables.foo, 'foo')
  asserts.are_equal(ctx.variables.bar, 2)
  asserts.is_in('context', ctx.variables)
예제 #3
0
def test_suites_decorator():
  """Tests that the test_suites decorator applies suite names properly."""

  @checkers.test_suites('suite1', 'suite2')
  @checkers.test
  def test_sample_for_suites():
    pass

  asserts.is_in('suite1', test_sample_for_suites.test_suite_names)
  asserts.is_in('suite2', test_sample_for_suites.test_suite_names)
예제 #4
0
def test_parameterize_decorator():
  """Tests that the parameterize decorator sets parameterizations properly."""

  @checkers.parameterize({
      'foo': {'x': 0},
      'bar': {'x': 1},
  })
  @checkers.test
  def test_sample_for_parameterize():
    pass
  asserts.is_in('foo', test_sample_for_parameterize.decorator_parameterizations)
  asserts.is_in('bar', test_sample_for_parameterize.decorator_parameterizations)
예제 #5
0
def test_setup_decorator():
  """Test that the setup decorator works properly."""

  def setup_func1():
    pass

  def setup_func2():
    pass

  @checkers.setup(setup_func1, setup_func2)
  @checkers.test
  def test_sample_for_setup():
    pass

  asserts.is_in(setup_func1.__name__, test_sample_for_setup.setup)
  asserts.is_in(setup_func2.__name__, test_sample_for_setup.setup)
예제 #6
0
def test_teardown_decorator():
  """Test that the teardown decorator works properly."""

  def teardown_func1():
    pass

  def teardown_func2():
    pass

  @checkers.teardown(teardown_func1, teardown_func2)
  @checkers.test
  def test_sample_for_teardown():
    pass

  asserts.is_in(teardown_func1.__name__, test_sample_for_teardown.teardown)
  asserts.is_in(teardown_func2.__name__, test_sample_for_teardown.teardown)
예제 #7
0
def test_test_suite_test_run():
  ts = test_suite.TestSuite('foo')
  ts.register(test_test_suite_from_module)
  ts.test_run = test_run.TestRun('Foo')
  asserts.is_not_none(ts.test_run)
  asserts.is_in(test_test_suite_from_module.full_name, ts.test_run.tests)
예제 #8
0
def test_assert_in_bad(item, collection):
    with asserts.expect_exception(AssertionError):
        asserts.is_in(item, collection)
예제 #9
0
def test_assert_in_ok(item, collection):
    asserts.is_in(item, collection)
예제 #10
0
def test_assert_in_bad(item, collection):
    with asserts.expect_exception(AssertionError):
        asserts.is_in(item, collection)
예제 #11
0
def test_assert_in_ok(item, collection):
    asserts.is_in(item, collection)